I'd like to use R to make a series of boxplots which are sorted by median value. Suppose then I execute:
boxplot(cost ~ type)
[ ] |
| [ ]
?reorder. The example seems to be what you want, but sorted in the opposite order. I changed
-count in the first line below to sort in the order you want.
bymedian <- with(InsectSprays, reorder(spray, -count, median)) boxplot(count ~ bymedian, data = InsectSprays, xlab = "Type of spray", ylab = "Insect count", main = "InsectSprays data", varwidth = TRUE, col = "lightgray")