On Thu, Nov 24, 2011 at 10:25 PM, Prof Brian Ripley <rip...@stats.ox.ac.uk> wrote: > Yes. That's a job for substitute (the second time today). > >> form <- formula(y1~x1) >> x <- eval(substitute(lm(f, anscombe), list(f = form))) >> summary(x) > > Call: > lm(formula = y1 ~ x1, data = anscombe) > That's what I wanted. Thanks!
However, I do want to simplify the syntax and define a new function: x.lm <- function(formula, data, ...) { eval(substitute(lm(f, data, ...), list(f = formula))) } For the simple case it works just fine > (form <- formula(y1~x1)) y1 ~ x1 > x <- x.lm(form, anscombe) But it fails when I try to input more lm() arguments: > (x <- x.lm(form, anscombe, subset=-5)) Error in eval(expr, envir, enclos) : ..1 used in an incorrect context, no ... to look in Am I doing something obviously wrong? Regards Liviu ______________________________________________ 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.