[R] several boxplots or bwplots into one graphic
Chuck Cleland
ccleland at optonline.net
Mon Jan 24 15:41:28 CET 2005
Your variables (var.*) seem to be on the same scale. How about
reshaping the data into a univariate layout and then using bwplot as
follows:
mydata <- data.frame(ID = 1:20, A = runif(20), B = runif(20),
C = runif(20), GROUP = rep(c(0,1), c(10,10)))
mydata.uni <- reshape(mydata, varying = list(c("A", "B", "C")),
v.names = "Y", timevar = "VAR", times = c("A",
"B", "C"), direction = "long")
library(lattice)
bwplot(Y ~ as.factor(GROUP) | VAR, data = mydata.uni, layout=c(3,1,1),
xlab="Group")
hope this helps,
Chuck Cleland
Christoph Lehmann wrote:
> Hi
> I have 10 variables and 2 groups. I know how to plot a bwplot for ONE
> var. e.g.
>
> var.a var.b var.c .. GROUP
> 0.2 0.5 0.2 .. 0
> 0.3 0.2 0.2 .. 0
> ..
> 0.1 0.8 0.7 .. 1
> 0.5 0.5 0.1 .. 1
> ..
>
>
> bwplot(var.a ~ GROUP, data = my.data)
>
> How can I plot 10 bwplots (or boxplots) automatically into one graphic?
> is there any function from lattice which can do this?
>
> thanks for a short hint
>
> christoph
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list