Description Usage Arguments Value See Also Examples
View source: R/dummify_across.R
This function allows you to make dummy variables across many variables at once. For example,
if you have two variables called sex (with values "male","female","other") and marital status
(with values "single", "married", "divorced", "widowed"), this function creates dummy
variables for both sex and marital status based off of their unique values. This function is
a wrapper of dummify()
that allows multiple variables to be passed in the same function
call. Currently, automatic renaming of variables and manual selection of reference categories
is limited to dummify()
.
1 | dummify_across(data, vars, reference = NULL)
|
data |
A dataframe containing the variables to be dummied. |
vars |
A list of column names or indices. Accepts variables integer, string, and factor values. |
reference |
If TRUE, it will leave the first value observed across each variable out as a reference category. Defaults to NULL, which leaves no variables as references. |
The inputted dataframe with additional columns containing all of the dummified variables
1 2 3 4 5 6 7 | install.packages("palmerpenguins")
penguins<-palmerpenguins::penguins
dummify_across(penguins, c("species","island","sex"))
dummify_across(penguins, c(1,2,7))
dummify_across(penguins, c("species","island","sex"), reference = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.