One of the nice features of R's formula syntax is that
you can create a character string containing a formula,
and pass it to the formula() function. For example:
xyplot(formula(paste(paste(paste('D',1:10,sep=''),collapse='+'),'X',sep='~')),data)
will do what you want.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
[email protected]
On Mon, 26 Jul 2010, Rajarshi Guha wrote:
Hi, I have a data.frame with columns named X, D1, D2, D3
I know I can get a single plot with 3 curves by doing
xyplot(D1 + D2 + D3 ~ X, data)
but in some cases I might have columns D1 ... D10.
Is there a way to plot all 10 columns without having to specify each
individual term?
(By analogy with formulae in lm, I thought, xyplot(. ~ X, data) would
work, but it didn't)
Thanks,
--
Rajarshi Guha
NIH Chemical Genomics Center
______________________________________________
[email protected] 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.
______________________________________________
[email protected] 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.