Dear R-sians.. I am trying to plot boxplots with side-by-side option.. I tried some of the posted suggestions and could not make it work due to unequal sizes of categories... e.g. weekly measured water depth values are categorized into 5 levels based on their values such measurement is again categorized into dichotomous levels - based on the result of a test I would like generate boxplot of water depth, with side-by-side display at dichotomous levels (0,1), for each category (1-5). However, dichotomous levels are not always available in each category.....e.g. category 1 may have all categorized as 0s, category 5 may have all categorized as 1s, category 3 may have 0s and 1s, and so on... I tried to use at=1:5+/- 0.1, add=T,xaxt="n" with complementary (subset(dichot=0) & subset(dichot=1)) datasets and it did not work.. I would highly appreciate your suggestions... Thanks and regards, Santosh [[alternative HTML version deleted]]
reproducible code. On Wed, Jun 24, 2009 at 8:53 AM, Santosh<santosh2005 at gmail.com> wrote:> Dear R-sians.. > > I am trying to plot boxplots with side-by-side option.. I tried some of the > posted suggestions and could not make it work due to unequal sizes of > categories... > > e.g. > weekly measured water depth values are categorized into 5 levels based on > their values > such measurement is again categorized into dichotomous levels - based on the > result of a test > > I would like generate boxplot of water depth, with side-by-side display at > dichotomous levels (0,1), for each category (1-5). > > However, dichotomous levels are not always available in each > category.....e.g. category 1 may have all categorized as 0s, category 5 may > have all categorized as 1s, category 3 may have 0s and 1s, and so on... > > I tried to use at=1:5+/- 0.1, add=T,xaxt="n" with complementary > (subset(dichot=0) & subset(dichot=1)) datasets ?and it did not work.. > > I would highly appreciate your suggestions... > > Thanks and regards, > Santosh > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
Try this Rich tmp <- data.frame( y=rnorm(100), category=rep(factor(letters[1:5]),each=20), level=rep(factor(0:1), length=100)) tmp table(tmp[,2:3]) tmp$y[with(tmp, category=="a" & level=0)] <- NA tmp$y[with(tmp, category=="a" & level==0)] <- NA tmp$y[with(tmp, category=="e" & level==1)] <- NA tmp$y[78:80] <- NA tmp[!is.na(tmp$y),] tmp2 <- tmp[!is.na(tmp$y),] table(tmp2[2:3]) bwplot(y ~ category | level, data=tmp2) bwplot(y ~ category | level, data=tmp2, layout=c(1,2)) bwplot(y ~ level | category, data=tmp2, layout=c(5,1)) bwplot(y ~ level | category, data=tmp2, layout=c(5,1))