[R] Drawing a line in xyplot

wcheckle wcheckle at jhsph.edu
Mon Apr 9 03:07:32 CEST 2012


i appreciate all the interest in my question, and thank you Elai for both of
your suggestions, which work very well.
Elai, your last code was particularly simple and helpful to generate the
figure i was looking for.

x11(height=8,width=11)
par(lend=2)
xdat = data.frame(mortality =c(5,
8,7,5,8,10,11,6,4,5,20,25,27,30,35,32,28,21,20,34,11,15,18,12,15,12,10,15,19,20),
type=
c(1, 1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3), attend =
c(1, 0,1,1,1,1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0))
xyplot ( mortality ~ factor(attend)|type,
panel=function(x,y)
{
panel.grid(lty=5)
panel.xyplot(x,y,pch=16,jitter.x=TRUE,col=1)
yy<- tapply(y,x,median)
panel.segments(x0=c(0.7,1.7), x1=c(1.3,2.3), y0= yy , y1= yy ,
col="red",lwd=5)
},
data = xdat, aspect=2:1,layout=c(3,1))

http://r.789695.n4.nabble.com/file/n4541912/trial.jpg 

as a side note, the par(lend=2) function did not square the ends of the
lines for panel.segments in xyplot (i was trying to get square ends instead
of round ends).

John: thank you for your information regarding latticeExtra and the layer
function, which will be helpful for future figures.


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



More information about the R-help mailing list