[R] Using all variables in a linear model

Gabor Grothendieck ggrothendieck at gmail.com
Wed Apr 21 01:17:31 CEST 2010


lm can take a data frame whose first column is the response so:

lm(rev(x))


On Tue, Apr 20, 2010 at 6:12 PM, Walter Yund IV <wyundiv at gmail.com> wrote:
> Hello,
>
> I am trying to automate linear regression for many different datasets, each
> with the same rough format (the last variable is the response).  I've been
> doing something like this:
>
>  lm=lm(x[,dim(x)[2]] ~ ., data=x)
>
> where the dot denotes all variables.  However, this means that the response
> is included as a predictor, which is obviously what I don't want.  How do I
> request that all the columns in my dataset be used as predictors, except for
> the response?
>
> Thanks,
>
> Walter
>
>        [[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.
>



More information about the R-help mailing list