Let's consider this data:
df = data.frame('score'=round(runif(15, 1, 10)),
'group'=paste0("a",rep(c(1,2,3),each=5)),
'category'=rep(c("big", "big", "big", "big", "small"), 3))
I would like to plot boxplots of this data with ggplot2
. What i want is: boxplot(score~group), but with the boxplots arranged according to the mean of the "big" individuals of each group.
I can't figure it out in a simple way, without creating new variables. OK to use Dplyr. Thanks.
I don't know if this qualifies as a simple way, I personally find it simple, but I use
dplyr
to find the means:In this case the order is:
In order to arrange the order of the boxplots according to the above you just need to do:
And that's it.