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
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
On 24 Jan 2005 at 14:44, 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?Hallo It probably depends on how you want to organise your boxplots. You can reformat your table to long format to get second grouping (a,b,...) by reshape (or reShape from Hmisc) and than use interaction and boxplot or bwplot(Group~var|second.grouping) Cheers Petr> > 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.htmlPetr Pikal petr.pikal at precheza.cz