[R] xyplot problem

2006-06-15 Thread Marc Bernard
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,
   
   

 __



[[alternative HTML version deleted]]

__
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


Re: [R] xyplot problem

2006-06-15 Thread Kevin E. Thorpe
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: [EMAIL PROTECTED]  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