data(dichodata)
# Dichotomize with all present categories
ex1 <- dichotomize(dichodata, categories = NULL)
head(ex1)
# Dichotomize with fixed set of categories
ex2 <- dichotomize(dichodata, categories = c('A','B','C','D'))
head(ex2)
# Dichotomize with NAs as 0s
ex3 <- dichotomize(dichodata, NAasNA = FALSE)
head(ex3)
Run the code above in your browser using DataLab