[R] ordering boxplots according to median

2006-03-22 Thread Talloen, Willem [PRDBE]
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@stat.math.ethz.ch

Re: [R] ordering boxplots according to median

2006-03-22 Thread Andrew Robinson
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

Re: [R] ordering boxplots according to median

2006-03-22 Thread Jacques VESLOT
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

Re: [R] ordering boxplots according to median

2006-03-22 Thread John Wilkinson (pipex)
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