Normalizes the accepted metadata inputs into a single tidy table with one row per dataset variable. A metacore object is unpacked into its dataset, variable, and derivation components; a data.frame is checked for the required dataset and variable columns and completed with any missing optional columns.

as_variable_metadata(metadata)

Arguments

metadata

Either a Metacore object or a data.frame with at least the columns dataset and variable. Optional columns label, type, origin, derivation, and is_derived are used when present.

Value

A tibble with columns dataset, variable, label, type, origin, derivation, and is_derived.

Examples

# The example ADaM metadata shipped in r4subdata.
meta <- as_variable_metadata(r4subdata::adam_metadata)
head(meta)
#> # A tibble: 6 × 7
#>   dataset variable label                     type  origin derivation is_derived
#>   <chr>   <chr>    <chr>                     <chr> <chr>  <chr>      <lgl>     
#> 1 ADSL    STUDYID  Study Identifier          Char  NA     NA         FALSE     
#> 2 ADSL    USUBJID  Unique Subject Identifier Char  NA     NA         FALSE     
#> 3 ADSL    SUBJID   Subject Identifier        Char  NA     NA         FALSE     
#> 4 ADSL    SITEID   Study Site Identifier     Char  NA     NA         FALSE     
#> 5 ADSL    AGE      Age                       Num   NA     NA         FALSE     
#> 6 ADSL    AGEU     Age Units                 Char  NA     NA         FALSE