[R] variable names in lm formula ~.

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue Jan 30 15:23:31 CET 2018


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
>suppose..)
>
>best,
>vito



More information about the R-help mailing list