I can easily create grouped box plots from the diamonds data set:
dd = diamonds[diamonds$color %in% c("E","J"),]
ggplot(dd, aes(x=cut, y=carat)) +
geom_boxplot(aes(fill=color), outlier.shape=NA)
# note: below does *not* work for `geom_text()`
ggplot(dd, aes(x=cut, y=carat, fill=color)) +
geom_boxplot(outlier.shape=NA)
How can I label each x
group defined by the fill
variable?
I am looking for a solution using stat_summary()
between each x
pair, to compute e.g. the p-value between each red and green pair below
This roughly corresponds to this question, but the difference is that here the data is grouped by fill
and I want to label those groups.