[R] Grouped Boxplot
soeren.vogel at eawag.ch
soeren.vogel at eawag.ch
Wed Mar 4 19:50:50 CET 2009
Pls forgive me heavy-handed data generation -- newby ;-)
### start ###
# example data
g <- rep.int(c("A", "B", "C", "D"), 125)
t <- rnorm(5000)
a <- sample(t, 500, replace=TRUE)
b <- sample(t, 500, replace=TRUE)
# what I actually want to have:
boxplot(a | b ~ g)
# but that does obviously not produce what I want, instead
i <- data.frame(g, a, rep("one", length(g)))
j <- data.frame(g, b, rep("two", length(g)))
names(i) <- c("Group", "Number", "Word")
names(j) <- c("Group", "Number", "Word")
k <- as.data.frame(rbind(i, j))
boxplot(k$Number ~ k$Word * k$Group)
### end ###
Questions: (1) Is there an easier way? (2) How can I get additional
space between the A:D groups?
Thank you
Sören
More information about the R-help
mailing list