Re: [R] adding the mean and standard deviation to boxplots

From: <Richard.Cotton_at_hsl.gov.uk>
Date: Mon, 4 Feb 2008 16:33:43 +0000


>> How can I add the mean and standard deviation to each of the boxplots
using the example provided in the boxplot function?  

boxplot(len ~ dose, data = ToothGrowth)
#You could add the mean as a point
points(tapply(len, dose, mean), col="red")

Alternatively, replace the median value with the mean, by writing a replacement for fivenum that calculates mean instead of median, then call bxp instead of boxplot.

As for the standard deviation, are you sure you want this? Standard deviation only makes sense if the data are normally distributed, and boxplots are typically used to examine how the data are distributed (i.e., if you knew they were normally distributed already, you wouldn't need to draw the boxplot).

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 04 Feb 2008 - 16:35:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 04 Feb 2008 - 17:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive