dictionary.apply {opalr} | R Documentation |
Apply the dictionary to a tibble
Description
Apply the dictionary described in a Opal Excel format as attributes of the tibble's columns.
Usage
dictionary.apply(tibble, variables, categories = NULL, merge = FALSE)
Arguments
tibble |
Tibble to be decorated. |
variables |
A data frame with one row per variable (column name) and then one column per property/attribute. |
categories |
A data frame with one row per category (columns variable and name) and then column per property/attribute. |
merge |
Either append attributes to existing ones or replace them. Default is FALSE, for dictionary consistency. |
Examples
## Not run:
data <- tibble::as_tibble(mtcars)
variables <- tibble::tribble(
~name, ~valueType, ~`label:en`, ~`label:fr`, ~`Namespace::Name`, ~unit, ~repeatable, ~index,
"mpg", "decimal", "Mpg label", "Mpg libellé", "Value1", "years", 0, 1,
"cyl", "decimal", "Cyl label", "Cyl libellé", "Value2", "kg/m2", 0, 2,
"disp", "decimal", "Disp label", "Disp libellé", NA, NA, 1, 3
)
categories <- tibble::tribble(
~variable, ~name, ~missing, ~`label:en`, ~`label:fr`,
"cyl", "4", 0, "Four", "Quatre",
"cyl", "6", 0, "Six", "Six",
"cyl", "8", 1, "Height", "Huit"
)
data <- dictionary.apply(data, variables, categories)
## End(Not run)
[Package opalr version 3.4.1 Index]