I would like to add lines between \"mean\" in my boxplot.
My code:
library(ggplot2)
library(ggthemes)
Gp=factor(c(rep(\"G1\",80),rep(\"G2\",80)))
Fc=fac
This is not elegant but try this
tmp1 = aggregate(Y~., DATA[DATA$Z == 100,], mean)
tmp2 = aggregate(Y~., DATA[DATA$Z == 50,], mean)
tmp1$X2 = tmp2$X
tmp1$Y2 = tmp2$Y
graphics.off()
ggplot(DATA, aes(x = factor(X), y = Y, fill = Z)) +
geom_boxplot(width = 0.5, outlier.shape = NA) +
geom_segment(data = tmp1,
aes(x = as.numeric(factor(X)) - 0.125, y = Y,
xend = as.numeric(factor(X2)) + 0.125, yend = Y2)) +
facet_grid(Gp ~ Fc)