lbl_define | R Documentation |
Creates a labelled
vector from an unlabelled atomic
vector using lbl_relabel
syntax, which allows grouping multiple
values into a single labelled value. Values not assigned a label will remain
unlabelled.
lbl_define(x, ...)
x |
An unlabelled atomic vector |
... |
Two-sided formulas where the left hand side is a label placeholder
(created with the |
A haven::labelled vector
Other lbl_helpers:
lbl_add()
,
lbl_clean()
,
lbl_collapse()
,
lbl_na_if()
,
lbl_relabel()
,
lbl()
,
zap_ipums_attributes()
age <- c(10, 12, 16, 18, 20, 22, 25, 27) # Note that values not assigned a new labelled value remain unchanged lbl_define( age, lbl(1, "Pre-college age") ~ .val < 18, lbl(2, "College age") ~ .val >= 18 & .val <= 22 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.