echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

rename grouped variable

Open Jorge-hercas opened this issue 3 years ago • 1 comments

Hello and I hope you are having a great day. I wanted to know if there is a possibility to rename observations when they are grouped. I tried to rename the following example but I couldn't get it to work :(

iris |> 
   group_by(Species) |> 
   e_charts(Sepal.Length) |> 
   e_scatter(Sepal.Width, name = c("example 1", "example 2", "example 3")) |> 
   e_tooltip(trigger = "axis")

Thanks for the help

Jorge-hercas avatar Jan 20 '22 17:01 Jorge-hercas

Hi Jorge-hercas,

I am not entirely sure what you intend, but can't you solve your problem within dplyr instead of echarts4r, like this:

iris |> 
  group_by(Species) |> mutate(Species = case_when(
    Species == "setosa" ~ "example 1",
    Species == "versicolor" ~ "example 2",
    Species == "virginica" ~ "example 3",
  )) |> 
  e_charts(Sepal.Length) |> 
  e_scatter(Sepal.Width) |> 
  e_tooltip(trigger = "axis")

rdatasculptor avatar Mar 10 '22 11:03 rdatasculptor