[R] get() within a command, specifically lmer
Greg.Snow at imail.org
Wed Jan 5 18:25:38 CET 2011
Formula syntax is different from regular syntax, it is "quoted" and not evaluated in the same way as regular commands (otherwise operations like '+' and '-' would do very different things).
For what you are trying to do, I would suggest creating the formula as a string using paste or sprintf, then use as.formula on that string. You can also use the substitute function, but that tends to be a bit more complicated.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Patrick McKann
> Sent: Wednesday, January 05, 2011 8:26 AM
> To: r-help at r-project.org
> Subject: [R] get() within a command, specifically lmer
> Hello all. Why doesn't this work?
> update(model,~.-z)###works, removes 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
> Any suggestions?
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help