labels | R Documentation |
Functions to extract information about the declared variable / value labels, or to declare such values if they are present in the data.
label(x)
label(x, ...) <- value
labels(x) <- value
x |
Any vector of values that should be declared as missing
(for |
... |
Other arguments, for internal use. |
value |
The variable label, or a list of (named) variable labels |
The function labels()
is a adaptation of the base function to the objects
of class declared
. In addition to the regular arguments, it has two
additional (logical) arguments called prefixed
(FALSE by default), to
retrieve the value labels prefixed with their values, and print_as_df
(TRUE by default) to print the result as a data frame.
labels()
will return a named vector.
label()
will return a single character string.
Other labelling functions:
drop_undeclare
,
measurement()
x <- declared(
c(-2, 1:5, -1),
labels = c("Good" = 1, "Bad" = 5, "DK" = -1),
na_values = c(-1, -2),
label = "Test variable"
)
x
labels(x)
labels(x, prefixed = TRUE)
labels(x) <- c("Good" = 1, "Bad" = 5, "DK" = -1, "Not applicable" = -2)
label(x)
label(x) <- "This is a proper label"
x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.