For a two level factor, this is relatively easy, since we just
replace the field with x==levels(x)[1]
or something like that, and
rename the field to indicate that TRUE is level 1 of the factor. This works
well for gender. For multi-level factors there is redundancy with multiple
new fields now containing FALSE, with only one TRUE for the matching level.
expandFactors(x, consider = names(x), sep = "", na.rm = TRUE,
verbose = FALSE)
data.frame to search for factors to convert
character vector of field names in the data frame to consider. Defaults to all fields
character scalar used to separate field prefixes from factor values in new column names
logical scalar: if NA data and/or NA levels, then covert to NA strings and expand these as for any other factor
single logical value, if TRUE
then produce verbose
messages
data.frame with no factors
PSAgraphics::cv.trans.psa