[R] 'beside' option for boxplots
Malcolm Ryan
malcolmr at cse.unsw.edu.au
Thu Jun 4 09:39:22 CEST 2009
Is there any way to get a boxplot of several data sets beside one
another on the same graph, as there is for barplot?
If I do:
d1 <- data.frame(a = c(rep(1:3, each = 3)), b = c(1:9))
d2 <- data.frame(a = c(rep(1:3, each = 3)), b = c(9:1))
boxplot(d1$b ~ d1$a)
boxplot(d2$b ~ d2$a, add=T)
It will show the two datasets on the one graph, but the middle point
will overlap.
What I want is a layout more like:
barplot(t(matrix(c(d1$b, d2$b), ncol=2)), beside=T)
only showing the boxes from the plot above instead of bars.
Can this be done?
Malcolm
More information about the R-help
mailing list