opalr (version 1.4.1)

harmo.dictionary_apply: Apply the dictionary to a tibble

Description

Apply the dictionary described in a Opal Excel format as attributes of the tibble's columns.

Usage

harmo.dictionary_apply(tibble, variables, categories = NULL)

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.

Examples

Run this code
# NOT RUN {
data <- tibble::as_tibble(mtcars)
variables <- tibble::tribble(
  ~name, ~valueType, ~`label:en`,  ~`Namespace::Name`, ~unit, ~repeatable, ~index,
  "mpg", "decimal", "Mpg label",  "Value1", "years", 0, 1,
  "cyl", "decimal", "Cyl label",  "Value2", "kg/m2", 0, 2,
  "disp", "decimal", "Disp label", 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 <- harmo.dictionary_apply(data, variables, categories)
# }

Run the code above in your browser using DataCamp Workspace