[R] Multiple Line Plots with xyplot

Elliot Joel Bernstein elliot.bernstein at fdopartners.com
Wed Nov 17 23:38:23 CET 2010


I'm trying to make multiple line plots, each with a different color, using the xyplot command. Specifically, I have an NxK matrix Y and an Nx1 matrix x. I would like the plot to contain a line for each (x, Y[,i]), i=1:K. I know something like 

xyplot(Y[,1] + Y[,2] + Y[,3] ~ x, type='l')

will work, but if Y is large, this notation can get very awkward. Is there a way to do something simpler, along the lines of 

xyplot(Y ~ x, type='l')

Thanks.

- Elliot

--
Elliot Joel Bernstein, Ph.D. | Research Associate | FDO Partners, LLC
134 Mount Auburn Street | Cambridge, MA | 02138
Phone: (617) 503-4619 | Email: elliot.bernstein at fdopartners.com



More information about the R-help mailing list