View source: R/prep_map_labels.R
prep_map_labels | R Documentation |
Map variables to certain attributes, e.g. by default their labels.
prep_map_labels(
x,
meta_data = "item_level",
to = LABEL,
from = VAR_NAMES,
ifnotfound,
warn_ambiguous = FALSE
)
x |
character variable names, character vector, see parameter from |
meta_data |
data.frame metadata data frame, if, as a |
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
|
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.
a character vector with:
mapped values
## Not run:
meta_data <- prep_create_meta(
VAR_NAMES = c("ID", "SEX", "AGE", "DOE"),
LABEL = c("Pseudo-ID", "Gender", "Age", "Examination Date"),
DATA_TYPE = c(DATA_TYPES$INTEGER, DATA_TYPES$INTEGER, DATA_TYPES$INTEGER,
DATA_TYPES$DATETIME),
MISSING_LIST = ""
)
stopifnot(all(prep_map_labels(c("AGE", "DOE"), meta_data) == c("Age",
"Examination Date")))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.