| combineCatVars {iNZightTools} | R Documentation |
Combine specified categorical variables by concatenating their values into one character, and returns the result along with tidyverse code used to generate it.
combineCatVars( .data, vars, sep = ".", name = paste(vars, collapse = sep), keep_empty = FALSE )
.data |
a dataframe with the columns to be combined |
vars |
a character vector of the categorical variables to be combined |
sep |
the separator to combine the values of the variables
in |
name |
a name for the new variable |
keep_empty |
logical, if |
When either variable is NA, the result is NA.
original dataframe containing a new column of the renamed categorical variable with tidyverse code attached
Owen Jin
combined <- combineCatVars(warpbreaks, vars = c("wool", "tension"), sep = "_")
cat(code(combined))
head(combined)