Skip to contents

Creates a mapping table of target updates for the control file, supporting aggregation and crosswalks for combined or topcoded targets. Use to generate new target names and level mappings for weighting and reporting pipelines.

Usage

create_target_update_table(update_idx, target_names, settings)

Arguments

update_idx

integer(1). Index of the target update in the settings list.

target_names

character vector. Target names in the control file.

settings

list. Settings list containing target_updates and target definitions.

Value

data.table. Mapping table of target updates. Columns:

  • Component target columns (if cross target)

  • old_targets : original target names

  • new_targets : new target names after update

  • Row order: by mapping and target group

Details

  • Identifies target group from settings using update_idx.

  • Uses regex pattern matching to select old target names from target_names.

  • Splits old target names into component levels using _by_ separator.

  • Handles cross targets (multi-level) and single targets.

  • Loops through update levels in settings, mapping old levels to new levels for each target group.

  • Aggregates old levels to new levels in mapping table.

  • Constructs new target names by concatenating component levels with _by_ and prefixing with target group.

  • Drops old target columns after mapping.

  • Returns a data.table with columns:

    • Component target columns (if cross target)

    • old_targets : original target names

    • new_targets : new target names after update

  • Error handling: none explicit; assumes valid settings and target names.

Settings

  • target_updates (direct): list of target updates and level mappings.

Examples

## Not run:
create_target_update_table(update_idx = 1, target_names, settings)
#> Error: object 'settings' not found
## End(Not run)