I want to plot mean and standard deviation bar by two levels of a factor. I found the solution on Plot mean and standard deviation by category.
According to the previous solution, I just get lineplot. However, I would like to get boxplot rather than lineplot. How could I get boxplots with sd bars?
set.seed(101)
y <- rnorm(100)
x <- gl(2, 50)
boxplot(y~x, las=1)
means <- by(y, x, mean); means
sds <- by(y, x, sd); sds
arrows(x0=c(1,2), y0=means-sds, y1=means+sds, col="blue", angle=90, length=0.1, code = 3, lwd=2)
points(means, pch=21, bg="red", col="blue", cex=2)