dummy_code | R Documentation |
Turns a categorical variable into a tibble of n-1 dummy-coded values. If x is a factor, the first level is omitted and thus treated as the reference level (to match the behavior of lm() and related functions). If x is not a factor, the first value in x is treated as the reference level. Variable names returned include a common prefix and a cleaned up version of the factor levels (without special characters and in snake_case).
dummy_code(x, prefix = NA, drop_first = TRUE, verbose = interactive())
x |
The categorical variable to be dummy-coded |
prefix |
String to be pre-fixed to the new variable names (typically the name of the variable that is dummy-coded). If NULL, variables are just named with the levels. If left as NA, the function will try to extract the name of the variable passed. |
drop_first |
Should first level be dropped? Defaults to TRUE |
verbose |
Should message with reference level be displayed? |
dummy_code(iris$Species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.