Evaluate an expression string in a data-frame scope
Source:R/forestsearch_helpers.R
safe_eval_expr.RdParses and evaluates expr in a restricted environment
containing only the columns of df (parent: baseenv()).
This isolates evaluation from the global environment, reducing
scope for unintended side effects.
Note
eval(parse()) is used intentionally here.
evaluate_comparison handles only single comparisons
(e.g., "er <= 0"); this function is needed for the compound
logical expressions produced by the ForestSearch subgroup enumeration
algorithm (e.g., "er <= 0 & nodes > 3"). Evaluation is
sandboxed: the environment contains only the columns of df
with baseenv() as parent, so neither the global environment
nor any package namespace is in scope. No user-supplied strings are
evaluated; only internally-constructed subgroup definition strings
reach this function.
See also
evaluate_comparison for the single-comparison
operator-dispatch alternative that avoids eval(parse()).