[R] lattice plots - variables in columns

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Mon Dec 4 21:39:04 CET 2006


Matt Pocernich said the following on 12/4/2006 12:32 PM:
> I an using xyplot in lattice.  I have data in a dataframe.  Some columns
> contains data, each from a different group.  Is there a direct way to 
> specify a range of column names as a grouping variables?  Currently, I 
> am stacking the data and creating a column with names.
> 
> Thanks,
> 
> Matt
> 

Hi, Matt,

Yes. Try this:

my.data <- data.frame(x = 1:10, y1 = 1:10, y2 = 11:20)
xyplot(y1 + y2 ~ x, my.data)
## or if you want y1,y2 in panels
xyplot(y1 + y2 ~ x, my.data, outer = TRUE)

HTH,

--sundar




More information about the R-help mailing list