Skip to content

Mean in bwplot

3 messages · Plantky, Charilaos Skiadas

#
Hi everyone,

Is there a way to include both mean and median in a bwplot? And what
should I do to convert the median dots into lines?

Thanks!
Plantky
#
On Mar 23, 2008, at 11:31 AM, Plantky wrote:

            
Did you look at the documentation for bwplot and panel.bwplot?

This should do it , adjust at will:

ex <- data.frame(x=1:10, y=rep(c("A","B"), 5))
bwplot(y~x, data=ex, panel=function(x,y,...) {
	panel.bwplot(x, y, pch="|", ...)
	panel.points(mean(x), y, col="red", ...)
})

If you want the mean lines to appear as lines as well, you'll likely  
want to look into the actual code of panel.bwplot, to see what it  
does when pch="|".
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
#
On Mar 23, 2008, at 1:37 PM, Charilaos Skiadas wrote:

            
Correction, this should have probably been:

   panel.points(tapply(x, y, mean), y, col="red", ...)

All this assuming you want horizontal boxplots.

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College