All

I want to overlay two variables on the same plot following their appropriate
grouping.  I have attempted to use subscripting in panel with panel.xyplot,
but I can't get the grouping to follow into the panel...here is an
example...


dat<-data.frame(
y= log(1:10),
y2=10:19,
 x=1:10,
grp = as.factor(1)
)

dat2<-data.frame(
 y= log(10:19),
y2= 20:29,
x=1:10,
 grp = as.factor(c(2))
)

dat<-rbind(dat, dat2)

# Here I plot both response variables on y axis by the same x
xyplot(y2 ~ x, dat, groups=grp, type="l")
xyplot(y ~ x, dat, groups=grp, type="l")

# I want to overlay both in the same plot to compare
xyplot(y~ x, dat,
 groups = grp,
ylim = c(0,40),
panel=function(x,y,subscripts, groups,...){
 panel.xyplot(x, y, type="l")
panel.xyplot(dat$x[subscripts], dat$y2[subscripts],type="l")
 }
)


Thanks

-- 
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

        [[alternative HTML version deleted]]

______________________________________________
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