formulas in variables in modeling functions
On Fri, 1 Jun 2001 Setzer.Woodrow@epamail.epa.gov wrote:
I first noticed this in gnls, but it also happens in lm, so I suspect the following phenomenon is universal in modeling functions. Modify the example from the lm help: model <- as.formula(weight ~ group) lm(model) The result will be printed:
lm(model)
Call:
lm(formula = model)
^^^^^^^^^^^^^^^^^
Coefficients:
(Intercept) groupTrt
5.032 -0.371
This is because in lm, (where the return value is z) z$call is set to cl,
and cl <- match.call().
My question is: would it break things to add the line
cl[["formula"]] <- formula
after
cl <- match.call()
?
It would. Think about how update() works. What's wrong with lm(weight ~ group) or if you need it eval(substitute(lm(model), model=model)) ? There is a difference between capturing the formula or using a reference to a formula.
Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._