What are you using the data frame argument for? If y, x1, x2, ..., xn were all the variables in the data frame all you need do is
myfun <- function(y, dat) { lm(y ~ ., dat) } but your question is very vague and ill-posed. -----Original Message----- From: Richard Nixon [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2003 2:50 AM To: [EMAIL PROTECTED] Subject: [R] lm with an arbitrary number of terms Hello folks, Any ideas how to do this? data.frame is a data frame with column names "x1",...,"xn" y is a response variable of length dim(data.frame)[1] I want to write a function function(y, data.frame){ lm(y~x1+...+xn) } This would be easy if n was always the same. If n is arbitrary how could I feed the x1+...+xn terms into lm(response~terms)? Thanks Richard -- Dr. Richard Nixon MRC Biostatistics Unit, Cambridge, UK http://www.mrc-bsu.cam.ac.uk/personal/richard Tel: +44 (0)1223 330382, Fax: +44 (0)1223 33038 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help