[R] get() within a command, specifically lmer

From: Patrick McKann <pcmckann_at_gmail.com>
Date: Wed, 05 Jan 2011 09:25:46 -0600


Hello all. Why doesn't this work?

d=data.frame(y=rpois(10,1),x=rnorm(10),z=rnorm(10),grp=rep(c('a','b'),each=5)) library(lme4)
model=lmer(y~x+z+(1|grp),family=poisson,data=d) update(model,~.-z)###works, removes z
var='z'
update(model,~.-get(var))##doesn't remove z update(model,~. -get(var,pos=d))###doesn't remove z

I am trying to remove z from the model in the update, but I can't do it using get(), which is what I would like to do for a more complicated program. There's something about environments and get() that I don't understand.

Any suggestions?

Thanks.

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 05 Jan 2011 - 15:28:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Jan 2011 - 17:40:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive