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
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
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
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