Try this: lm(y ~., tmp)
On Fri, May 21, 2010 at 3:54 AM, Yuan Jian <jayuan2...@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@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@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.