lbl_add {ipumsr} | R Documentation |
Add labels for unlabelled values
Description
Add labels for values that don't already have them in a
labelled
vector.
Usage
lbl_add(x, ...)
lbl_add_vals(x, labeller = as.character, vals = NULL)
Arguments
x |
A |
... |
Arbitrary number of label placeholders created with |
labeller |
A function that takes values being added as an argument and returns the labels to associate with those values. By default, uses the values themselves after converting to character. |
vals |
Vector of values to be labelled. If |
Value
A labelled
vector
See Also
Other lbl_helpers:
lbl()
,
lbl_clean()
,
lbl_define()
,
lbl_na_if()
,
lbl_relabel()
,
zap_ipums_attributes()
Examples
x <- haven::labelled(
c(100, 200, 105, 990, 999, 230),
c(`Unknown` = 990, NIU = 999)
)
# Add new labels manually
lbl_add(
x,
lbl(100, "$100"),
lbl(105, "$105"),
lbl(200, "$200"),
lbl(230, "$230")
)
# Add labels for all unlabelled values
lbl_add_vals(x)
# Update label names while adding
lbl_add_vals(x, labeller = ~ paste0("$", .))
# Add labels for select values
lbl_add_vals(x, vals = c(100, 200))
[Package ipumsr version 0.8.1 Index]