Map variables to certain attributes, e.g. by default their labels.
util_map_labels( x, meta_data ="item_level", to = LABEL, from = VAR_NAMES, ifnotfound, warn_ambiguous =FALSE)
Arguments
x: character variable names, character vector, see parameter from
meta_data: data.frame old name for item_level
to: character variable attribute to map to
from: character variable identifier to map from
ifnotfound: list A list of values to be used if the item is not found: it will be coerced to a list if necessary.
warn_ambiguous: logical print a warning if mapping variables from from to to produces ambiguous identifiers.
Returns
a character vector with:
mapped values
Details
This function basically calls colnames(study_data) <- meta_data$LABEL, ensuring correct merging/joining of study data columns to the corresponding metadata rows, even if the orders differ. If a variable/study_data-column name is not found in meta_data[[from]] (default from = VAR_NAMES), either stop is called or, if ifnotfound has been assigned a value, that value is returned. See mget, which is internally used by this function.
The function not only maps to the LABEL column, but to can be any metadata variable attribute, so the function can also be used, to get, e.g. all HARD_LIMITS from the metadata.