[R] too many var in lm

Dimitris Rizopoulos d.rizopoulos at erasmusmc.nl
Wed Aug 17 15:35:17 CEST 2011


another approach is:

Df <- as.data.frame(cbind(rcauchy(100), matrix(runif(100*50), ncol = 50)))
fit <- lm(V1 ~ ., data = Df)
fit


I hope it helps.

Best,
Dimitris


On 8/17/2011 3:28 PM, R. Michael Weylandt wrote:
> The most elegant solution is going to depend on where you data comes from,
> but one way to do it if you have a matrix of data:
>
> D = cbind(rcauchy(100), matrix(runif(100*50),ncol=50)) # Some nonsense data
> lm(D[,1] ~ D[,-1])
>
> If you let us know how your data is set up, a more specific response can be
> given.
>
> Hope this helps,
>
> Michael Weylandt
>
> On Wed, Aug 17, 2011 at 9:23 AM, carol white<wht_crl at yahoo.com>  wrote:
>
>> Hello,
>> It might be an easy question but if you have many variables to fit in the
>> lm function, how do you take all without specifying var1+var2+...+var2100 in
>> the terms parameter in response ~ terms?
>>
>> Cheers,
>>
>> Carol
>>
>> ______________________________________________
>> 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.
>>
>
> 	[[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.
>

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/



More information about the R-help mailing list