I would appreciate any help in correcting my misunderstanding of the
following:
substitute(quote(x+a), env = list(a=5))
quote(x + 5) ## as expected
substitute(quote(x+a), env = list2env(list(a=5)))
quote(x + 5) ## as expected
substitute(quote(x+a), env = .GlobalEnv)
quote(x + a) ## unexpected
I conclude from this that there is something special about .GlobalEnv that
does not allow it to behave as documented for the env argument in
?substitute, to wit:
"env:
an environment or a list object. Defaults to the current evaluation
environment."
I would be grateful for any insight, as I am clearly missing something.
Note: (though I don't think this matters):
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Cheers to all,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )