[R] How to use a sequence of covariates in linear model (lm)?

Joshua Wiley jwiley.psych at gmail.com
Fri Feb 3 17:09:54 CET 2012


Or pass the covariates as a matrix.  See ?lm for details.

On Feb 3, 2012, at 7:51, "R. Michael Weylandt" <michael.weylandt at gmail.com> wrote:

> Usually that's what the dot in a formula is used for.
> 
> E.g.,
> 
> data(iris)
> str(iris)
> lm(Petal.Width ~ ., data = iris)
> 
> Michael
> 
> On Fri, Feb 3, 2012 at 10:45 AM, michael <tufemichael at gmail.com> wrote:
>> I have a high dimension linear model:
>> 
>> y~ x1 + x2 + ... + x_n.  n is very large.
>> 
>> For linear model fit, I wish to use a sequence of covariates, say X1 to
>> X200, without typing every single covariate in the function (my variable
>> names are coded in the pattern of X1, X2, ...). I think all.var or
>> all.names might have worked but I can't figure out how to do it. Please
>> help.
>> 
>> Thanks,
>> 
>> Michael
>> 
>>        [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at r-project.org 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.
> 
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list