to.dummy {REAT} | R Documentation |
This function creates a dataset of dummy variables based on an input character vector.
to.dummy(x)
x |
A character vector |
This function transforms a character vector x
with c
characteristics to a set of c
dummy variables whose column names corresponding to these characteristics marked with “_DUMMY”.
A data.frame
with dummy variables corresponding to the levels of the input variable.
This function contains code from the authors' package MCI.
Thomas Wieland
Greene, W. H. (2012): “Econometric Analysis”. 7th edition. Harlow : Pearson.
charvec <- c("Peter", "Paul", "Peter", "Mary", "Peter", "Paul")
# Creates a vector with three names (Peter, Paul, Mary)
to.dummy(charvec)
# Returns a data frame with 3 dummy variables
# (Mary_DUMMY, Paul_DUMMY, Peter_DUMMY)