Re: [R] metaprogramming with lm

From: Erik Iverson <iverson_at_biostat.wisc.edu>
Date: Wed, 12 Nov 2008 18:38:11 -0600

The special name "." may be used on the right side of the "~" operator, to stand for all the variables in a data.frame other than the response.

--John Chambers, Statistical Models in S, p. 101

So, if the y and Xi (in your case) were the only variables in mydata, then

lm(y ~ . , data = mydata)

would be of use.

Erik

June Kim wrote:
> Hello,
>
> Say I want to make a multiple regression model with the following expression:
>
> lm(y~x1 + x2 + x3 + ... + x_n,data=mydata)
>
> It gets boring to type in the whole independent variables, in this
> case x_i. Is there any simple way to do the metaprogramming for this?
> (There are different cases where the names of the independent
> variables might sometimes have apparent patterns or not)
>
> ______________________________________________
> 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. Received on Thu 13 Nov 2008 - 00:40:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Nov 2008 - 01:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive