Thanks all, I see where I misunderstood the issue. I would like to suggest
though to add a similar warning to the help page of with() and within()
like there is already on subset() and transform().
Cheers
Joris
On Wed, Apr 1, 2015 at 9:18 PM, Duncan Murdoch
wrote:
> On 01/04/2015 2:33 PM, Joris
On 01/04/2015 2:33 PM, Joris Meys wrote:
Thank you for the insights. I understood as much from the code, but I
can't really see how this can cause a problem when using with() or
within() within a package or a function. The environments behave like
I would expect, as does the evaluation of the a
There is no important difference between transform() and within(). They
have the same pitfalls. If your general code is unable to guarantee the
scope of the symbol resolution, the behavior of the code is unlikely to be
very predictable.
I've explored some solutions in the S4Vectors package, see th
Thank you for the insights. I understood as much from the code, but I can't
really see how this can cause a problem when using with() or within()
within a package or a function. The environments behave like I would
expect, as does the evaluation of the arguments. The second argument is
supposed to
Ah, of course. Embarassing, the "environment" and "new.env" wires got
crossed in my head somehow.
Joris - The take away, as Duncan's point suggests, is that e (which is
where expr is evaluated) is the "environment form" of data. So that's why
the lookup hits things in data before anything else.
S
On 01/04/2015 1:35 PM, Gabriel Becker wrote:
Joris,
The second argument to evalq is envir, so that line says, roughly, "call
environment() to generate me a new environment within the environment
defined by data".
I think that's not quite right. environment() returns the current
environment,
Joris,
The second argument to evalq is envir, so that line says, roughly, "call
environment() to generate me a new environment within the environment
defined by data".
Note that that is is only generating e, the environment that expr will be
evaluated within in the next line (the call to eval).
Dear list members,
I'm a bit confused about the evaluation of expressions using with() or
within() versus subset() and transform(). I always teach my students to use
with() and within() because of the warning mentioned in the helppages of
subset() and transform(). Both functions use nonstandard ev