Re: [R] xyplot problem

From: Kevin E. Thorpe <kevin.thorpe_at_utoronto.ca>
Date: Fri 16 Jun 2006 - 01:39:24 EST

Marc Bernard wrote:
> Dear all,
>
> I have created the following data (that you can run) in order to explain my problem:
>
> y <- rep(c(1,2), 8)
> id <- rep(1:8,each=2)
> x1 <- rep(c("-a","+a"), each = 8)
> x2 <- rep(c("-b","+b"), each = 2, times = 4)
> x3 <- rep(c("-c", "+c"), each = 4,2)
> df <- data.frame(cbind(id,y,x1,x2,x3))
>
> If I do:
>
> xyplot(y~ x3|x1*x2,data=df,groups=id,type = "b")
>
> then my id's are joined by lines which is what I want. However when I wanted to add an horizontal line for each panel by using "panel.abline" the lines disapears, i.e.
>
> xyplot(y~ x3|x1*x2,data=df,groups=id,type = "b",panel=function(x,y)
> {
> panel.xyplot(x,y)
> panel.abline(h=1.5)
> }
> )
>
>
> I would be grateful if someone can tell me how can I correct the second statement in order to have horizontal lines for each panel and each id are joined by lines.
>
> Thank you,
>
> Bernard,

This appears to work for me.

xyplot(y~ x3|x1*x2,data=df,groups=id,type = "b",

   panel=function(x,y,groups,...) {

     panel.superpose(x,y,groups,...)
     panel.abline(h=1.5)})


-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: kevin.thorpe@utoronto.ca  Tel: 416.946.8081  Fax: 416.946.3297

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Jun 16 01:50:01 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 16 Jun 2006 - 02:12:53 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.