evaluate_cuts_once: Cache and validate cut expressions efficiently

View source: R/get_FSdata_helpers.R

evaluate_cuts_onceR Documentation

Cache and validate cut expressions efficiently

Description

Evaluates all cut expressions once and caches results to avoid redundant evaluation. Much faster than evaluating repeatedly.

Usage

evaluate_cuts_once(confs, df, details = FALSE)

Arguments

confs

Character vector of cut expressions.

df

Data frame to evaluate expressions against.

details

Logical. Print details during execution.

Details

This replaces multiple eval(parse()) calls scattered throughout get_FSdata. By caching results, we avoid:

  1. Repeated parsing of expressions

  2. Repeated evaluation on dataframe

  3. Redundant uniqueness checks

Value

List with:

  • evaluations: List of evaluated vectors (logical TRUE/FALSE) for each cut

  • is_valid: Logical vector indicating which cuts produced >1 unique value

  • has_error: Logical vector indicating which cuts failed to evaluate

Examples

df <- data.frame(age = c(40, 55, 70), size = c(20, 30, 25))
confs <- c("age <= 50", "size > 25")
evaluate_cuts_once(confs, df)

forestsearch documentation built on Nov. 15, 2026, 9:06 a.m.