I just cannot think of how to do it:
I want to take the first variable (column) of a data frame and regress it against all other variables.
bla <- function (dat) {
reg <- lm(whateverthefirstofthevariablenamesis ~., data=dat)
return(reg)
}What kind of function do I have to take instead of the whateverthefirstofthevariablenamesis,
eval(), substitute(), get(), ...
to correctly compute this regression?
With lm(get(names(dat)[1] ~., data=dat) there are no errors, but the first variable also shows up among the regressors.
Thanks for help. Christian Hoffmann
--
Dr.sc.math.Christian W. Hoffmann, http://www.wsl.ch/staff/christian.hoffmann
Mathematics + Statistical Computing e-mail: [EMAIL PROTECTED]
Swiss Federal Research Institute WSL Tel: ++41-44-73922- -77 (office)
CH-8903 Birmensdorf, Switzerland -11(exchange), -15 (fax)
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
