[R] lattice variable by page

Sundar Dorai-Raj sundar.dorai-raj at PDF.COM
Wed Jul 28 23:47:02 CEST 2004



Matt Pocernich wrote:

> Hi,
> 
> Using lattice's xyplot, is it possible to specify a variable to group
> plots by page.  For example, if I have
> 
> xyplot(y~x|A*B*C)
> 
> could I get a page created for each unique value in
> variable C ?  I am hoping to avoid having pages with the same strip above
> each plot on a page.
> 
> Thanks,
> 
> M
> 

Others may have a better solution, but when I've done this in the past I 
used a for loop with subset:

# assuming C is a factor to use nlevels
for(ci in nlevels(C)) {
   pl <- xyplot(y ~ x | A * B,
                subset = C == ci,
                main = paste("C ==", ci))
   print(pl)
}

HTH,
--sundar




More information about the R-help mailing list