[R] Mean in bwplot

Charilaos Skiadas
Sun, 23 Mar 2008 17:37:38 -0000

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

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

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="|".

> Thanks!
> Plantky

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College