dichotomixed.Rd
Dichotomizes the factor variables in a data frame composed of mixed format variables, i.e. transforms the factors into an indicator matrix (also known as disjunctive table) and keeps the numerical variables.
dichotomixed(data, out = "numeric")
data frame of categorical and numerical variables
character string defining the format for dichotomized variables in the output data frame. Format may be "numeric" (default) or "factor".
Returns a data frame with numerical variables and dichotomized factor variables
## Dichotomizes Music example data frame
data(Music)
## recodes Age as numerical, for the sake of the example
Music$Age <- as.numeric(Music$Age)
## dichotomization
dic <- dichotomixed(Music)
str(dic)
#> 'data.frame': 500 obs. of 24 variables:
#> $ FrenchPop.No : num 0 1 1 1 0 0 1 0 1 1 ...
#> $ FrenchPop.Yes: num 0 0 0 0 1 1 0 1 0 0 ...
#> $ FrenchPop.NA : num 1 0 0 0 0 0 0 0 0 0 ...
#> $ Rap.No : num 1 0 1 1 1 1 1 1 1 0 ...
#> $ Rap.Yes : num 0 1 0 0 0 0 0 0 0 1 ...
#> $ Rap.NA : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ Rock.No : num 0 1 0 0 1 0 1 0 1 1 ...
#> $ Rock.Yes : num 1 0 1 1 0 1 0 1 0 0 ...
#> $ Rock.NA : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ Jazz.No : num 1 0 1 1 1 1 1 1 1 1 ...
#> $ Jazz.Yes : num 0 0 0 0 0 0 0 0 0 0 ...
#> $ Jazz.NA : num 0 1 0 0 0 0 0 0 0 0 ...
#> $ Classical.No : num 1 1 1 1 0 1 1 1 1 0 ...
#> $ Classical.Yes: num 0 0 0 0 1 0 0 0 0 0 ...
#> $ Classical.NA : num 0 0 0 0 0 0 0 0 0 1 ...
#> $ Gender.Men : num 1 0 0 0 0 1 0 1 0 1 ...
#> $ Gender.Women : num 0 1 1 1 1 0 1 0 1 0 ...
#> $ Age : num 2 1 1 1 2 3 2 1 2 2 ...
#> $ OnlyMus.Daily: num 0 0 1 0 0 0 0 0 0 0 ...
#> $ OnlyMus.Often: num 0 1 0 0 0 0 0 0 0 0 ...
#> $ OnlyMus.Rare : num 1 0 0 1 0 0 0 0 1 0 ...
#> $ OnlyMus.Never: num 0 0 0 0 1 1 1 1 0 1 ...
#> $ Daily.No : num 1 0 0 0 1 1 1 1 0 0 ...
#> $ Daily.Yes : num 0 1 1 1 0 0 0 0 1 1 ...