lbl_add | R Documentation |
Add labels for values that don't already have them in a
labelled
vector.
lbl_add(x, ...)
lbl_add_vals(x, labeller = as.character, vals = NULL)
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 |
A labelled
vector
Other lbl_helpers:
lbl()
,
lbl_clean()
,
lbl_define()
,
lbl_na_if()
,
lbl_relabel()
,
zap_ipums_attributes()
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.