[Rd] anyway to get R unevaluated expr independent on arguments
Simon Urbanek
simon.urbanek at r-project.org
Thu Apr 7 23:42:00 CEST 2011
On Apr 7, 2011, at 5:18 PM, Zheng, Xin (NIH) [C] wrote:
> Hi there,
>
> Suppose the cmd is "a<-3", I can parse the cmd sexp with R_ParseVector and eval it. My question is - is it possible to parse a cmd like "a <- ?", afterwards evaluation will give corresponding result depend on different argument? In other words, '?' is just a placeholder.
>
Well, you can use a dummy symbol and replace it later, e.g. parse "a <- `*dummy*`" and then before you evaluate you simply replace all occurrences of the "*dummy*" symbol with any value you want.
That said, we are in a functional language, so you can actually do it more natively by using a closure like "function(.var1){ a <- .var1 }" - that saves you the substitution part and is more clean.
Cheers,
Simon
More information about the R-devel
mailing list