Skip to contents

Attempt to guess the names of a measure set using regular expressions (or regexs).

Usage

guess_measure_sets(
  data,
  measure_regexs = getOption("expstudy.default_measure_regexs"),
  measure_set_prefixes = getOption("expstudy.default_measure_set_prefixes"),
  measure_set_suffixes = getOption("expstudy.default_measure_set_suffixes")
)

Arguments

data

A data.frame that houses an experience study.

measure_regexs

A named list of patterns to use as regexs when guessing columns in the study dataset to be used for one study measure in each measure set. There must be one column for each measure in a measure set (actuals, expecteds, exposures, and variances). Defaults to getOption('expstudy.default_measure_regexs').

measure_set_prefixes, measure_set_suffixes

Character vectors that will be use to differentiate the same measure in one measure set from another measure set. Using NULL indicates that the study measures do not differ by prefix/suffix and will error if more than one column is guessed using the measure regex for a single measure. Defaults to measures sets not differing by prefix (measure_set_prefixes = NULL) but do differ by count and amount suffixes (measure_set_prefixes = c('_CNT', '_AMT')).

If the experience study has columns that follow a consistent naming structure, this function can seamlessly provide other expstudy functions information on the study measures to use for various calculations.

Value

A named list of measure sets that identify common variables used for expstudy analyses.

Examples

guess_measure_sets(mortexp)
#> $CNT
#>             actuals           exposures           expecteds           variances 
#>   "MORT_ACTUAL_CNT" "MORT_EXPOSURE_CNT" "MORT_EXPECTED_CNT" "MORT_VARIANCE_CNT" 
#> 
#> $AMT
#>             actuals           exposures           expecteds           variances 
#>   "MORT_ACTUAL_AMT" "MORT_EXPOSURE_AMT" "MORT_EXPECTED_AMT" "MORT_VARIANCE_AMT" 
#>