[R] Drawing a line in xyplot

wcheckle wcheckle at jhsph.edu
Sun Apr 8 04:29:46 CEST 2012


Thank you David, the bwplot option does what I need:

x11(height=8,width=11)
bwplot ( mortality~ attend|type,
 pch=95,cex=5,col=2,
 par.settings=list(
  box.rectangle = list(col = "transparent"),
  box.umbrella = list(col = "transparent"),
  plot.symbol = list(col = "transparent")
 ),
 panel=function(x,y,...){
  panel.grid(lty=5)
  panel.xyplot(x,y,pch=16,jitter.x=TRUE,col=1)
  panel.bwplot(x,y,...)
 },
data = x,aspect=2:1,layout=c(3,1))


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 (condition on
packet.number and loop over segments), wondering if I can ask for your help
for the correct code (my attempt resulted in all three mean lines within
each panel):

x11(height=8,width=11)
xyplot ( mortality ~ attend|type, 
panel=function(x,y)
{
panel.grid(lty=5)
panel.xyplot(x,y,pch=16,jitter.x=TRUE,col=1)
for(i in 1:3)
{
panel.segments(x0=c(0.7, 1.7),
x1=c(1.3, 2.3),
y0=c(tapply(x$mortality[x$type==i], x$attend[x$type==i], median)), 
y1=c(tapply(x$mortality[x$type==i], x$attend[x$type==i],
median)),col="red",lwd=4)
}	
},
data = x,aspect=2:1,layout=c(3,1))

thank you again. I also found your info on data.frame useful.



--
View this message in context: http://r.789695.n4.nabble.com/Drawing-a-line-in-xyplot-tp4538689p4540389.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list