[Rd] question on docs for delayedAssign and substitute
Duncan Murdoch
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
> > x #- new!
> [1] "new!"
> > substitute(x)
> 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)
> substitute(x)
x
> e <- new.env()
> delayedAssign("x", 1+2, assign.env = e)
> substitute(x, e)
1 + 2
The documentation for substitute() indicates this, but perhaps not
entirely unambiguously.
Duncan Murdoch
>
> -- Tony Plate
>
> > sessionInfo()
> R version 2.4.1 (2006-12-18)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> attached base packages:
> [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
> [7] "base"
>
> other attached packages:
> g.data
> "1.6"
> >
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list