O'Reilly logo
  • Ruben Laguna thinks this is interesting:

condition_call contains the expression condition. So when we evaluate condition_call it also evaluates condition,


Cover of Advanced R


when subscramble calls subset2(sample_df, condition) the substitute(condition) inside subset2 will resolve to “condition” not “a >= 4”. So it will try to find the binding “condition” in sample_df and since it’s not there it will go up to parent.frame() and resolve “condition” there. It will resolve to “a >= 4” but then it will continue and try to find binding “a” at the environment of subscramble (not restarting the lookup at sample_df) and fail to find “a” in that environment.