combine_vars | R Documentation |
Combine chosen variables of any class by concatenating them into one factor variable, and returns the result along with tidyverse code used to generate it.
combine_vars(
data,
vars,
sep = ":",
name = NULL,
keep_empty = FALSE,
keep_na = TRUE
)
data |
a dataframe with the columns to be combined |
vars |
a character vector of the variables to be combined |
sep |
a character string to separate the levels |
name |
a name for the new variable |
keep_empty |
logical, if |
keep_na |
logical, if |
original dataframe containing new columns of the new categorical variable with tidyverse code attached
Owen Jin, Zhaoming Su
combined <- combine_vars(warpbreaks, vars = c("wool", "tension"), sep = "_")
cat(code(combined))
head(combined)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.