Description Usage Arguments Value Examples
Takes any variable and splits into separate variables by unique value, with a binary indicator (0/1) for each. Uses stats::model.matrix to perform the dummifying. By default, all new dummy variables have the name var_'unique_value' where var_ is the supplied variable name and unique_value is the value for which the indicator is 1. Set 'prefix = FALSE' to remove var_ from the new variable name. By default, this function errors when var has more than 20 distinct values. Set 'force = TRUE' to dummify anyway. TODO: Check how missing values are handled. Allow ... list of variable input
1 |
df |
a tbl |
var |
variable to dummify (will be coerced to character before dummifying) |
prefix |
(default = TRUE) prepend var name to dummy variable names? |
force |
(default = FALSE) allow creation of more than 20 dummies? |
the original tbl with dummy variables added on the end.
1 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.