Skip to contents

Checks that column group row sums match person and household totals in weighting input files. Use to validate group consistency for targets.

Usage

check_group_sum(tbl, grp_pattern, stop_on_fail = TRUE, regex = FALSE)

Arguments

tbl

data.table. Target data table.

grp_pattern

character(1). Regex or prefix for group columns.

stop_on_fail

logical. If TRUE, stops on failure.

regex

logical. If TRUE, treats grp_pattern as regex.

Value

logical. TRUE if group sums match total, FALSE otherwise.

Details

  • Matches columns by group pattern (prefix or regex).

  • Sums group columns and compares to total column.

  • Prints mismatched rows and stops if requested.

  • Returns TRUE if all rows match, FALSE otherwise.

Settings

None.

See also

  • scripts/weighting/target_validation.R

Other validation helpers: check_daypat_results(), check_group_sums(), check_initial_weights(), check_ref_counts(), check_weight_skew()

Examples

## Not run:
check_group_sum(target_puma, settings)
#> Error: object 'target_puma' not found
## End(Not run)