as_labelled | R Documentation |
Convert a factor to a haven::labelled variable
as_labelled(x)
x |
Factor. |
Returns a labelled variable with values and labels according to the levels in the factor. This should roundtrip with forcats::as_factor. Additionally, a variable label can be set.
x <- factor(c("b", "b", "a")) attr(x, "label") <- "variable label" x as_labelled(x) all.equal(x, x %>% as_labelled() %>% forcats::as_factor())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.