On Apr 7, 2012, at 11:35 AM, wcheckle wrote:

here is the data (fyi this is made-up data)

x = as.data.frame (
cbind
(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
),
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
),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)))
names(x)=c("mortality","type","attend")

Sidebar not related to the question at hand: I would like to get hands on the person who is teaching the malpractice of using the form as.data.frame(cbind(vectors))) and ....what would be sufficiently motivational? ... strangulation would be a bit severe, but perhaps carefully applied thumb pressure to the cricoid cartilage for sufficient interval to gain attention? I have seen several instances of that (mal)form in various rhelp-ish venues in the last couple of weeks and it is a common source of obscure error.

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

The reason for NOT using cbind is that it forces all vectors to have the same mode. The whole point of having data.frames is to allow you to mix modes. So that constriction is completely boneheaded.

And please learn to use spaces.


here is the image:
http://r.789695.n4.nabble.com/file/n4539596/x.jpg

revised code with image:

x11(height=8,width=11)
xyplot ( mortality ~ factor(attend)|type,
panel=function(x,y){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))

http://r.789695.n4.nabble.com/file/n4539596/x1.jpg

i am trying to replicate the "red" mean lines on the xyplot graph

abline won't do it. llines may be able to do it, but i don't know how to
use/implement


I didn't say to 'abline'. I said 'panel.abline' and the help page for panel.abline also include 'panel.segments' which it becomes clear you wanted ... now that we have data and can see what you were looking at.

xyplot(mortality ~ type, data=xdat,
               panel=function(x,y){
                   panel.xyplot(x,y, jitter.x=TRUE)
                   panel.segments(x0=c(.9, 1.9, 2.9),
                                   x1=c(1.1,2.1,3.1),
y0=tapply(xdat$mortality, xdat $type, median), y1=tapply(xdat$mortality, xdat $type, median),
                             col="red", lwd=3 )
                       })


thanks



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

______________________________________________
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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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