[R] A question about boxplot: mean and median

Rob Steele rob at fatkat.com
Fri Apr 15 19:11:26 CEST 2005


> I have worked through the examples given in the help
> on boxplot().  If I am reading it right, only the
> median is produced (as a default), which is
> represented by the horizontal line inside the box. 
> What argument do I need to specify if I want to show
> the mean as well?

Try this:

boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
points(sapply(split(InsectSprays$count, InsectSprays$spray), mean), col = 'red')




More information about the R-help mailing list