[R] Drawing a line in xyplot
wcheckle
wcheckle at jhsph.edu
Sat Apr 7 03:41:38 CEST 2012
i am trying to replicate the following graph using xyplot :
attach(x)
plot ( jitter(type), mortality, pch=16, xlim = c(0.25, 3.75))
lines ( c(1-0.375,1.375) , c ( median(mortality[type==1]),
median(mortality[type==1])), lwd=5,col=2)
lines ( c(2-0.375,2.375) , c ( median(mortality[type==2]),
median(mortality[type==2])), lwd=5,col=2)
lines ( c(3-0.375,3.375) , c ( median(mortality[type==3]),
median(mortality[type==3])), lwd=5,col=2)
detach(x)
in the above graph, i draw a median line for "mortality" (range from 5 to
35) by "type" (1,2 or 3). i now have an additional variable "attend" (0 or
1). within each panel (three panel, one for each "type"), i would like to
draw the median "mortality" for each instance of "attend". i have been able
to get as far as plotting everything but the median lines:
x11(height=8,width=11)
xyplot ( mortality ~ attend|type,
panel=function(x,y,subscripts){panel.grid(lty=5);
panel.xyplot(x,y,pch=16,jitter.x=TRUE,col=1)},
strip=strip.custom(which.given=1, bg="orange"),data
=x,aspect=2:1,layout=c(3,1))
any suggestions on how to add the median lines of "mortality" for each
instance of "attend" within each panel of "type"?
thank you
--
View this message in context: http://r.789695.n4.nabble.com/Drawing-a-line-in-xyplot-tp4538689p4538689.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list