View source: R/loadDataADaMSDTM.R
getLabelVar | R Documentation |
The label is extracted either (in this order):
if label
is specified: from this label based on names,
or directly from this label if label
and var
are of length 1 (if available)
if labelVars
is specified: from the specified vector of labels,
based on names (if available)
if data
is specified: from the 'label' attribute
of the corresponding column in data
(if available)
If the label is not available, the input variable is returned.
getLabelVar(var, data = NULL, labelVars = NULL, label = NULL)
var |
Character vector with variables of interest. |
data |
Data.frame with data. |
labelVars |
Named character vector with variable labels (names are the variable code),
usually extracted from |
label |
(Named) Character vector with user-specified label for |
Named character vector with label, var
is no label is available
Laure Cougnaud
data(dataADaMCDISCP01) labelVars <- attr(dataADaMCDISCP01, "labelVars") # (upon reading the data with haven: attributes should directly available in each column) getLabelVar(data = dataADaMCDISCP01, var = "AEREL") # but if the data as data.frame is subsetted, label is lost # so better to use 'labelVars': getLabelVar(var = "AEREL", labelVars = labelVars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.