On Apr 21, 2009, at 10:42 AM, Andreas Christoffersen wrote:

Hi,

ggplot/qplot is great - it has really helped me do some nice things.
However, simple boxplot of different columns/variables is a bit
tricky, because of (i think) qplot's generic Y conditional on X input
form. Se below.

# Some data:
a <- rnorm(100)
b <- rnorm(100,1,2)
c <- rnorm(100,2,0.5)
# normal boxplot of a,b,c
boxplot(a,b,c) # Looks good
library(ggplot2) # loads qqplot2
# Tries do replicate the simple boxplot
qplot(a,b,c, geom="boxplot") # Not good
# Workaround
d <- c(a,b,c)
e <- c(rep("a",100),rep("b",100),rep("c",100))
qplot(e,d,geom="boxplot") # Works - but there must be a simpler way?

qplot(ind, values, data=stack(data.frame(a,b,c)), geom="boxplot")

I first tried stack(list(a,b,c)) but did not get the expected results. If anyone wants to enlighten me on why, I would be happy to offer a rewrite of the stack help page that clarifies my inability to parse it correctly in its current incarnation.


What is the simple to compare multiple variables like this?

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
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