[Rd] question on docs for delayedAssign and substitute
murdoch at stats.uwo.ca
Tue Feb 13 21:11:03 CET 2007
On 2/13/2007 1:34 PM, Tony Plate wrote:
> The help files for delayedAssign and substitute both say that
> substitute() can be used to see the expression associated with a
> promise. However, I can't see how to do that. When I try the example
> in help file for delayedAssign I don't see substitute() extracting the
> promise, e.g.:
> > msg <- "old"
> > delayedAssign("x", msg)
> > msg <- "new!"
> > substitute(x) #- I would expect to see 'msg' here
> > x #- new!
>  "new!"
> > substitute(x)
> Has this functionality been removed, and the docs not updated? Or am I
> missing something?
This is a misfeature that has been around forever. The substitute()
function works differently when the env argument is the global
environment than it does in general.
> delayedAssign("x", 1+2)
> e <- new.env()
> delayedAssign("x", 1+2, assign.env = e)
> substitute(x, e)
1 + 2
The documentation for substitute() indicates this, but perhaps not
> -- Tony Plate
> > sessionInfo()
> R version 2.4.1 (2006-12-18)
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> attached base packages:
>  "stats" "graphics" "grDevices" "utils" "datasets" "methods"
>  "base"
> other attached packages:
> R-devel at r-project.org mailing list
More information about the R-devel