fac2dummies | R Documentation |
Convert a factor variable with n levels to n dummy variables.
fac2dummies(GADSdat, var)
GADSdat |
A |
var |
A character vector with the name of the factor variable. |
Newly created variables are named as the original variable with the suffix "_a"
, "_b"
and so on. Variable labels
are created by using the original variable label (if available) and adding the value label of the corresponding level.
All missing codes are forwarded to all dummy variables.
Returns a GADSdat
containing the newly computed variables.
## create an example GADSdat
suppressMessages(gads <- import_DF(iris))
## transform factor variable
gads2 <- fac2dummies(gads, var = "Species")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.