Search code examples
rrbokeh

How to create a Box-plot of nested/grouped categories in rbokeh?


I need to create a nested category box-plot where the x-axis is a combination of 2 factor(category) groups. In ly_boxplot(), the x argument can either be a numeric vector or a factor. Is there a way that it will accept a combined factor, say, of 2 or more factors?

The picture below is taken from this link.

How can I create such a plot using rbokeh library in R?

Box-plot with a grouped category on the x-axis nested category box-plot


Solution

  • Use the interaction function.

    library(rbokeh)
    figure(ylab = "Length (mm?)", xlab="Dose (mg/day) : Supplement") %>%
      ly_boxplot(len, interaction(dose,supp), data = ToothGrowth)
    

    enter image description here