[Rd] evaluation in transform versus within

Joris Meys jorismeys at gmail.com
Wed Apr 1 19:21:34 CEST 2015


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 evaluation and are
to be used only interactively.

I've never seen that warning on the help page of with() and within(), so I
assumed both functions can safely be used in functions and packages. I've
now been told that both functions pose the same risk as subset() and
transform().

Looking at the source code I've noticed the extra step:

e <- evalq(environment(), data, parent)

which, at least according to my understanding, should ensure that the
functions follow the standard evaluation rules. Could somebody with more
knowledge than I have shed a bit of light on this issue?

Thank you
Joris

-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Mathematical Modelling, Statistics and Bio-Informatics

tel :  +32 (0)9 264 61 79
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]



More information about the R-devel mailing list