> I'm trying to add a set of reference lines to a multipanel xyplot > xyplot(y ~ x | Visit, > panel = function(x, y, ...){ > panel.xyplot(x, y, ...) > abline(v = c(0.5, 1)) > }) > However, the reference lines are different for different visits.
I would do it with the groups parameter. xyplot (y ~ x | Visit, groups=Visit, panel=function(x,y,subscripts,groups,...) { panel.xyplot(x,y,...) g <- unique(groups[subscripts]) # g is the unique value of Visit occuring in this panel # so plot whatever lines you like, as a function of g } ) The groups argument to xyplot is an arbitrary vector of the same length as the data you are plotting. The function xyplot splits the data into panels. To each panel function it passes two arguments: group, which is just the same as the groups argument passed to xyplot; and subscripts, a vector of integers indexing the entries that will appear in this panel. Since in this case groups=Visit and the plot conditions on Visit, groups[subscripts] contains identical elements. If you had passed groups=SomethingElse to xyplot, groups[subscripts] would contain several values. > Any suggestions? Which page of the various manuals did I skim too quickly? The documentation I worked from is that for xyplot. And I looked at the definition of panel.superpose. Damon Wischik. ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help