View source: R/forestsearch_helpers.R
| safe_eval_expr | R Documentation |
Parses 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.
safe_eval_expr(df, expr)
df |
Data frame providing column names as variables. |
expr |
Character. Expression to evaluate
(e.g., |
Result of evaluating expr, or NULL on failure.
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.
evaluate_comparison for the single-comparison
operator-dispatch alternative that avoids eval(parse()).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.