echarts4r
echarts4r copied to clipboard
Grouped box plot with multiple variables
Is there a way to create a grouped box plot with multiple grouping variables using {echarts4r}?
I would like to create a grouped box plot with multiple variables comparable to this {ggplot2} plot: https://www.r-graph-gallery.com/265-grouped-boxplot-with-ggplot2.html
I have tried the following:
variety = rep(LETTERS[1:7], each=40)
treatment = rep(c("high","low"),each=20)
note = seq(1:280)+sample(1:150, 280, replace=T)
data.frame(variety, treatment , note) |>
echarts4r::group_by(variety, treatment) |>
echarts4r::e_charts() |>
echarts4r::e_boxplot(note) |>
echarts4r::e_legend()
But it gives me this:
I have also tried using e_add_nested
but it doesn't seem to work for boxplots.
I just noticed that has already come up in issue 253 but no clean solution was available at the time. Have any developments been made on this?
I would love this feature too. I've been using bar charts as a workaround (where the multiple grouping works as expected), but often boxplots are just so much more appropriate. :)
#253
Created a gist function to do it -> https://gist.github.com/munoztd0/c860717d1f29e8a1b9114c46e945202e
https://github.com/JohnCoene/echarts4r/issues/253#issuecomment-1204012312