Dear R-users, Does anyone knows how I can order my serie of boxplots from lowest to highest median (which is much better for visualization purposes). thanks in advance, willem [[alternative HTML version deleted]]
Willem, use the "at=" argument, and feed it the rank of the medians eg require(MASS) data(iris) boxplot(iris$Sepal.Width ~ iris$Species) # Not ordered boxplot(iris$Sepal.Width ~ iris$Species, at=rank(tapply(iris$Sepal.Width, iris$Species, median))) # Ordered I hope that this helps, Andrew On Wed, Mar 22, 2006 at 09:59:09AM +0100, Talloen, Willem [PRDBE] wrote:> Dear R-users, > > Does anyone knows how I can order my serie of boxplots from lowest to > highest median (which is much better for visualization purposes). > > thanks in advance, > willem > > [[alternative HTML version deleted]] > > ______________________________________________ > 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-- Andrew Robinson Department of Mathematics and Statistics Tel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 Email: a.robinson at ms.unimelb.edu.au http://www.ms.unimelb.edu.au
boxplot(count~spray, InsectSprays) spray2 <- with(InsectSprays, factor(spray, levels=levels(spray)[order(tapply(count,spray,median))])) boxplot(count~spray2, InsectSprays) Talloen, Willem [PRDBE] a ?crit :>Dear R-users, > >Does anyone knows how I can order my serie of boxplots from lowest to >highest median (which is much better for visualization purposes). > >thanks in advance, >willem > > [[alternative HTML version deleted]] > >______________________________________________ >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 > > >
Use reorder ---- # boxplot with increasing order of medians s2<-with(InsectSprays,reorder(spray,count,median)) with(InsectSprays,boxplot(count~s2)) # boxplot with decreasing order of medians s2<-with(InsectSprays,reorder(spray,-count,median)) with(InsectSprays,boxplot(count~s2)) John Talloen, Willem wrote-->Dear R-users, > >Does anyone knows how I can order my serie of boxplots from lowest to >highest median (which is much better for visualization purposes). > >thanks in advance, >willem >--