Try this: lm(freeny)
On Sun, Nov 29, 2009 at 8:49 AM, Matthieu Stigler < matthieu.stig...@gmail.com> wrote: > Hi > > My goal is to do a (multiple) regression, just knowing that my Y variables > will be the say k first variables of a matrix/data frame. I thought I should > do it with eval(parse)) but encounter a strange problem. > > See: > lm(y~.-y, data=freeny) #that's what I want to do in the one equation case > #Problem is I don't know name of the variable... only that it is the first > one... > #so idea is to just take first name > a<-colnames(freeny) > #and then use eval(parse(text=a[1])) > > #it works if I replace y on either the left or right side: > lm(eval(parse(text=a[1]))~.-y, data=freeny) #does the same > lm(y~.-eval(parse(text=a[1])), data=freeny) > > #but not if I do this call twice: > lm(eval(parse(text=a[1]))~.-eval(parse(text=a[1])), data=freeny) > #variable I wanted to remove (y) ist still there > > Do you understand why I can call eval(parse) only once? Should I try a > update workaround? Or have idea of any other solution? Maybe there is > something much simpler I'm missing:-( > > Thanks a lot!!! > > Matthieu Stigler > > ______________________________________________ > 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. > [[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.