Validate subgroup definitions against a data frame
Source:R/run_subgroup_sims.R
validate_subgroups.RdEvaluates 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, andgrp.- data
A data frame carrying the covariates the
idexpressions reference (e.g.dgm$df_sourceordgm$df_super).- cutpoints
Named list of scalars exposed as columns (e.g.
list(age_med = 53)), matching the runner'scutpointsargument.- benchmarks
A
benchmark_spec()(orNULL) whose membership columns are stubbed as0Lduring validation.