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

From: <>
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).


Mathematical Sciences Unit

ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} mailing list PLEASE do read the posting guide 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 Please read the posting guide before posting to the list.

list of date sections of archive