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)
This would g
Beware of missing values, you have to add na.rm = TRUE
for it to work. If not, the code simply doesn't work. It took me hours to found that out.
bymedian <- with(InsectSprays, reorder(spray, -count, median, **na.rm = TRUE**)
boxplot(count ~ bymedian, data = InsectSprays,
xlab = "Type of spray", ylab = "Insect count",
main = "InsectSprays data", varwidth = TRUE,
col = "lightgray")