Skip to content
Prev 81976 / 398502 Next

Impaired boxplot functionality - mean instead of median

On Thu, 2005-12-01 at 23:27 +0300, Evgeniy Kachalin wrote:
If we take SDs out of the picture for the moment, we can do something
like this:

 # Do the boxplot as you want using the formula
 boxplot(breaks ~ wool + tension, data = warpbreaks)

 # Get the means using tapply() with an interaction of the 
 # factor levels for each group
 means <- with(warpbreaks, tapply(breaks, 
                                  list(interaction(wool, tension)),
                                  mean, na.rm = TRUE))

 # Now add the means to the boxplot, where the 
 # x axis values are 1:number of groups by default
 points(1:length(means), means, pch = 19)
Generally best to "reply to all", which gets the message back to the
thread participants quickly as well as the list archive for use by
others during searches.

HTH,

Marc Schwartz