Hello R users and Hadley,

Back again with a little problem in ggplot2 =o) (ggplot 0.8.1, R 2.8.0)

Here the problem :

library(ggplot2)

df <- data.frame(id = 1:100, x1 = c(rnorm(50), rnorm(50, 1)), x2 =
c(rnorm(50), rnorm(50, 1.5)), x3 = c(rnorm(50, 0.5), rnorm(50, 2.5)), group
= as.factor(rep(c("a", "b"), each = 50)))
df.melt <- melt(df, id = c("id", "group"))
head(df.melt)

p <- ggplot(df.melt, aes(variable, value))
p + geom_boxplot(aes(fill = group))
# This graph is great, but I would like to have two panels, one for group
'a', and one for group 'b'
# With this code, I can't have one boxplot for each variable x1, x2 and x3
p + geom_boxplot(aes(fill = group)) + facet_wrap(~group)
# but it's working with geom_point
p + geom_point(aes(color = group)) + facet_wrap(~group)

Best regards.

david

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to