as_category | R Documentation |
Converts a vector object to a categorical object, typically a column in a data frame. The categories come from non-missing values present in the object and are added to an associated data dictionary (when present).
as_category(x)
x |
A vector object to be coerced to categorical. |
A vector with class haven_labelled.
haven::labelled()
{
library(dplyr)
mtcars <- tibble(mtcars)
as_category(mtcars[['cyl']])
head(mtcars %>% mutate(cyl = as_category(cyl)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.