Skip to content

Using group_by to one-line plot multiple boxplots does not set the x axis labels correctly #219

Description

@lianos

First: thank you for the package, I've only just encountered it, but it looks like it has a lot of promise.

It seems like in order to draw multiple box plots on the x-axis w/ out writing e_boxplot(...) for every value over x, we need to use group_by()

So, taking the example from the e_boxplot() man page which has data in a wide format, we have:

library(dplyr)
library(echarts4r)

df <- data.frame(
  x = c(1:10, 25),
  y = c(1:10, -6))

df %>%
  e_charts() %>%
  e_boxplot(x, outliers = TRUE) %>% 
  e_boxplot(y, outliers = TRUE)

If we had multiple categories we wanted to create boxplots for across the x-axis, that can get tedious, so it seems we need to rather convert the data into a long format, and use group_by, like so:

dfl <- data.frame(
  var = rep(c("x", "y"), each = nrow(df)),
  value = c(df$x, df$y))

dfl %>% 
  group_by(var) %>% 
  e_charts() %>% 
  e_boxplot(value)
  1. Just want to clarify that this is the suggested way to do that(?)
  2. The issue is that when we plot the data in this way, the labels on the x-axis or the boxplots are all "value" instead of "x" and "y".

Perhaps there is a way to use the name parameter in the e_boxplot() to address this, but not quite sure how if so.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions