On Sat, Apr 7, 2012 at 8:29 PM, wcheckle <wchec...@jhsph.edu> wrote:

> Thank you David, the bwplot option does what I need:
<snip>
> However, I am interested in also learning how to do it in xyplot as well.  I
> wasn’t able to follow the last two set of instructions

That was me. Sorry for any confusion. wcheckle, these were not
instructions but ramblings on an earlier code which used the original
data.frame inside the lattice panel function, which in my view is an
added complication in the case of only 2-3 conditioning variables. You
were not meant to try and follow (the alternative was given in the
form of bwplot).
Your original post had two plots - in base graphics you had one
conditional variable (type) and median lines, and a second was lattice
with 2 variables (attend|type) without median lines. You were offered
2 solutions - David's to reproduce the first plot in lattice, and the
bwplot to add medians to the second.
You could work through the examples in lattice and on-line to find
there is a multitude of ways to add features to grid/lattice plots. An
example with panel.segments might look (untested) something like:

panel=function(x,y,...)
{
panel.xyplot(x,y,...)
yy<- tapply(y,x,median)
panel.segments(x0, x1, y0= yy , y1= yy , col="red",lwd=4)
}

Hope that clarifies things, and again sorry everyone for any confusion
that may have resulted.

Best,
Elai

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to