dummies2char | R Documentation |
Convert a set of dummy variables into a set of character variables.
dummies2char(GADSdat, dummies, dummyValues, charNames, checkVarNames = TRUE)
GADSdat |
A |
dummies |
A character vector with the names of the dummy variables. |
dummyValues |
A vector with the values which the dummy variables represent. |
charNames |
A character vector containing the new variable names. |
checkVarNames |
Logical. Should |
A set of dummy variables is transformed to an equal number of character variables.
The character variables are aligned to the left and the remaining character variables are set to NA
.
For each new variable the missing codes of the respective dummy variable are reused.
Returns a GADSdat
.
## create an example GADSdat
dummy_df <- data.frame(d1 = c("eng", "no eng", "eng"),
d2 = c("french", "french", "no french"),
d3 = c("no ger", "ger", "no ger"),
stringsAsFactors = TRUE)
dummy_g <- import_DF(dummy_df)
## transform dummy variables
dummy_g2 <- dummies2char(dummy_g, dummies = c("d1", "d2", "d3"),
dummyValues = c("english", "french", "german"),
charNames = c("char1", "char2", "char3"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.