[R] vaiable in lm
Gabor Grothendieck
ggrothendieck at gmail.com
Fri May 21 12:46:02 CEST 2010
Try this:
lm(y ~., tmp)
On Fri, May 21, 2010 at 3:54 AM, Yuan Jian <jayuan2008 at yahoo.com> wrote:
> Hi,
>
> if I know the colnames x and y in the following example, I can easily to do lm.
> tmp <- data.frame(x=c(1,1.2),y=c(1,2))
> lm(y ~ x, data=tmp)
>
> when the colnames are variable, what should I do? for example
> colnames(tmp)[1] <- paste("aa",1,sep="_")
> lm(y ~ paste("aa",1,sep="_"), data = tmp)
> it gives me error.
>
>
>
>
>
>
> [[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