[Rd] formulas in variables in modeling functions
Prof Brian Ripley
Fri, 1 Jun 2001 15:37:23 +0100 (BST)
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)
> The result will be printed:
> > lm(model)
> lm(formula = model)
> (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
> cl <- match.call()
It would. Think about how update() works.
What's wrong with
lm(weight ~ group)
or if you need it
? There is a difference between capturing the formula or using a
reference to a formula.
Brian D. Ripley, email@example.com
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: firstname.lastname@example.org