Try this: ix <- 1:2 lm(as.matrix(freeny[ix]) ~., freeny[-ix])
On Sun, Nov 29, 2009 at 8:56 AM, Matthieu Stigler < matthieu.stig...@gmail.com> wrote: > Thanks for answering so fast!! > >> >> lm(freeny) >> > :-) > Ok that's working for the one equation case :-) Was example case... > > But now I want to have not only first column of freeny on the left but both > first? And I don't know their names a priori... > > Thanks! > >> >> On Sun, Nov 29, 2009 at 8:49 AM, Matthieu Stigler < >> matthieu.stig...@gmail.com <mailto: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 <mailto: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.