Description Usage Arguments See Also Examples
View source: R/category-variables.R
These are convenience functions for license data, similar to factor_var
but operate on data frames (useful for piping) and produce a check summary.
1 2 3 4 5 6 7 8 9 10 11 12 13 | df_factor_var(df, var, levels, labels, suppress_check = TRUE, ...)
df_factor_sex(df, var = "sex", levels = 1:2, labels = c("Male",
"Female"), ...)
df_factor_res(df, var = "res", levels = c(1, 0),
labels = c("Resident", "Nonresident"), ...)
df_factor_R3(df, var = "R3", levels = 1:4, labels = c("Carry",
"Renew", "Reactivate", "Recruit"), ...)
df_factor_age(df, var = "age", levels = 1:7, labels = c("0-17",
"18-24", "25-34", "35-44", "45-54", "55-64", "65+"), ...)
|
df |
data frame: Input data frame |
var |
character: Name of numeric variable to convert |
levels |
numeric: Levels for input numeric vector |
labels |
labels: Labels to use for output factor vector |
suppress_check |
logical: If TRUE, does not print a coding summary |
... |
Other arguments passed to |
Other functions for working with category variables: factor_var
,
label_categories
,
recode_agecat
1 2 3 4 5 6 | library(dplyr)
data(history)
x <- history %>%
df_factor_R3(suppress_check = FALSE) %>%
df_factor_res(suppress_check = FALSE) %>%
df_factor_sex(suppress_check = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.