[R] adding the mean and standard deviation to boxplots

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Mon Feb 4 17:33:43 CET 2008


>> 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}}



More information about the R-help mailing list