validate_subgroups: Validate subgroup definitions against a data frame

View source: R/run_subgroup_sims.R

validate_subgroupsR Documentation

Validate subgroup definitions against a data frame

Description

Evaluates every subgroup id expression against data (augmented with flag_itt = 1L, the scalar cutpoints as columns, and 0-valued benchmark membership columns) and fails with a named, collected error if any expression errors, is non-logical, or has the wrong length. Run automatically at the top of run_subgroup_sims() so that a typo in a subgroup definition stops the study in milliseconds instead of surfacing as a silent all-NA column after the simulation loop.

Usage

validate_subgroups(
  subgroups,
  data,
  cutpoints = list(),
  benchmarks = benchmark_spec()
)

Arguments

subgroups

List of subgroup definitions; each element a list with character scalars id (an R expression over columns), name, and grp.

data

A data frame carrying the covariates the id expressions reference (e.g. dgm$df_source or dgm$df_super).

cutpoints

Named list of scalars exposed as columns (e.g. list(age_med = 53)), matching the runner's cutpoints argument.

benchmarks

A benchmark_spec() (or NULL) whose membership columns are stubbed as 0L during validation.

Value

Invisibly TRUE; errors otherwise.


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