This function leverages metadata available in a metacore object to apply labels to a data frame.
Examples
mc <- metacore::spec_to_metacore(
metacore::metacore_example("p21_mock.xlsx"),
quiet=TRUE
)
#>
#> Metadata successfully imported
#> Loading in metacore object with suppressed warnings
dm <- haven::read_xpt(metatools_example("dm.xpt"))
set_variable_labels(dm, mc, dataset_name = "DM")
#> # A tibble: 306 × 25
#> STUDYID DOMAIN USUBJID SUBJID RFSTDTC RFENDTC RFXSTDTC RFXENDTC RFICDTC
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 CDISCPILOT01 DM 01-701-… 1015 "2014-… "2014-… "2014-0… "2014-0… ""
#> 2 CDISCPILOT01 DM 01-701-… 1023 "2012-… "2012-… "2012-0… "2012-0… ""
#> 3 CDISCPILOT01 DM 01-701-… 1028 "2013-… "2014-… "2013-0… "2014-0… ""
#> 4 CDISCPILOT01 DM 01-701-… 1033 "2014-… "2014-… "2014-0… "2014-0… ""
#> 5 CDISCPILOT01 DM 01-701-… 1034 "2014-… "2014-… "2014-0… "2014-1… ""
#> 6 CDISCPILOT01 DM 01-701-… 1047 "2013-… "2013-… "2013-0… "2013-0… ""
#> 7 CDISCPILOT01 DM 01-701-… 1057 "" "" "" "" ""
#> 8 CDISCPILOT01 DM 01-701-… 1097 "2014-… "2014-… "2014-0… "2014-0… ""
#> 9 CDISCPILOT01 DM 01-701-… 1111 "2012-… "2012-… "2012-0… "2012-0… ""
#> 10 CDISCPILOT01 DM 01-701-… 1115 "2012-… "2013-… "2012-1… "2013-0… ""
#> # ℹ 296 more rows
#> # ℹ 16 more variables: RFPENDTC <chr>, DTHDTC <chr>, DTHFL <chr>, SITEID <chr>,
#> # AGE <dbl>, AGEU <chr>, SEX <chr>, RACE <chr>, ETHNIC <chr>, ARMCD <chr>,
#> # ARM <chr>, ACTARMCD <chr>, ACTARM <chr>, COUNTRY <chr>, DMDTC <chr>,
#> # DMDY <dbl>