natverse / nat

NeuroAnatomy Toolbox: An R package for the (3D) visualisation and analysis of biological image data, especially tracings of single neurons.
https://natverse.org/nat/
64 stars 29 forks source link

subset.neuronlist does not have a parent.generations argument #140

Closed jefferis closed 10 years ago

jefferis commented 10 years ago

https://github.com/jefferis/nat/blob/master/R/neuronlist.R#L217-L226

jefferis commented 10 years ago

This is actually related to jefferislab/nat.nblast/issues/11. The question is, where is the best place to determine 1) if an incoming expression should be substituted and 2) what the fall-back environment should be.

See:

http://adv-r.had.co.nz/Computing-on-the-language.html#calling-from-another-function

for discussion

jefferis commented 10 years ago

Note that Hadley Wickham strongly recommends having a separate function rather than controlling non-standard evaluation using an argument, but this is not possible for plot3d.neuronlist (though it would be for subset.neuronlist)

jefferis commented 10 years ago

My conclusion is that we do not need a parent.generations argument. Rather any calling function should pre-substitute the expression using the appropriate calling environment. This does however have one issue to think about. If there is a variable in the calling environment that has the same name as a data.frame column, it is the callee that takes priority whereas right now it is the data.frame column that takes priority.

jefferis commented 10 years ago

Hmm, changed my mind about this again. substitute(x, parent.frame()) does not seem to behave as expected, because some expressions need to be evaluated in the parent.frame, not merely substituted