# [Rd] formulas in variables in modeling functions

**Setzer.Woodrow@epamail.epa.gov
**
Setzer.Woodrow@epamail.epa.gov

*Fri, 01 Jun 2001 10:23:03 -0400*

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()
?
The result of this is:
>* lm.new(model)
*
Call:
lm.new(formula = weight ~ group)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Coefficients:
(Intercept) groupTrt
5.032 -0.371
R. Woodrow Setzer, Jr. Phone:
(919) 541-0128
Experimental Toxicology Division Fax: (919) 541-5394
Pharmacokinetics Branch
NHEERL MD-74; US EPA; RTP, NC 27711
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._