[R] variable names in lm formula ~.
bgunter.4567 at gmail.com
Tue Jan 30 17:12:09 CET 2018
"data: a data frame from which the meaning of the special symbol . can
be inferred. It is unused if there is no . in the formula."
So this seems to me to be an obscure bug, as I have found no warning
against this admittedly confusing but still, I think, legal syntax.
> d <- data.frame(log = runif(10), x = 1:10)
> y <- rnorm(10,5)
> m1 <- lm(y ~ ., data = d)
y ~ log + x
> m2 <- update(m1, formula =log(y) ~.)
log(y) ~ log + x
> m3 = lm(log(y) ~., data =d)
log(y) ~ x
As always, correction appreciated if I'm wrong.
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Jan 30, 2018 at 6:23 AM, Jeff Newmiller
<jdnewmil at dcn.davis.ca.us> wrote:
> Functions are first class objects, so some kind of collision is bound to happen if you do this... so don't.
> Sent from my phone. Please excuse my brevity.
> On January 30, 2018 3:11:56 AM PST, "Vito M. R. Muggeo" <vito.muggeo at unipa.it> wrote:
> >dear all,
> >Is the following intentional? Am I missing anything in documentation?
> >d<-data.frame(y=rnorm(10,5,.5),exp=rnorm(10), age=rnorm(10))
> >formula(lm(exp(y)~exp+age, data=d))
> >#--> exp(y) ~ exp + age
> >formula(lm(exp(y)~., data=d))
> >#--> exp(y) ~ age
> >variable 'exp' (maybe indicating "experience") is not included in the
> >model. The same happens with 'log' (and other function names, I
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help