Returns the control term (a vector for permitted values and a tibble for code lists) for a given variable. The dataset can be optionally specified if there is different control terminology for different datasets

get_control_term(metacode, variable, dataset = NULL)

Arguments

metacode

metacore object

variable

A variable name to get the controlled terms for. This can either be a string or just the name of the variable

dataset

A dataset name. This is not required if there is only one set of control terminology across all datasets

Value

a vector for permitted values and a 2-column tibble for codelists

Examples

meta_ex <- spec_to_metacore(metacore_example("p21_mock.xlsx"))
#> Warning: core from the ds_vars table only contain missing values.
#> 
#> supp_flag from the ds_vars table only contain missing values.
#> 
#> The following words in value_spec$origin are not allowed: 
#>     edt
#> 
#> 
#> dataset from the supp table only contain missing values.
#> 
#> variable from the supp table only contain missing values.
#> 
#> idvar from the supp table only contain missing values.
#> 
#> qeval from the supp table only contain missing values.
#> 
#> Warning: The following derivations are never used:
#>  SUPPAE.QVAL: see value level metadata
#>  SUPPDM.QVAL: see value level metadata 
#> 
#> Warning: The following codelist(s) are never used:
#>  DRUG DICTIONARY
#>  MEDICAL HISTORY DICTIONARY 
#> 
#> 
#>  Metadata successfully imported
get_control_term(meta_ex, QVAL, SUPPAE)
#> # A tibble: 2 × 2
#>   code  decode
#>   <chr> <chr> 
#> 1 N     No    
#> 2 Y     Yes   
get_control_term(meta_ex, "QVAL", "SUPPAE")
#> # A tibble: 2 × 2
#>   code  decode
#>   <chr> <chr> 
#> 1 N     No    
#> 2 Y     Yes