data(efc)
summary(efc$c12hour)
table(dicho(efc$c12hour))
table(dicho(efc$c12hour, "mean"))
table(dicho(efc$c12hour, "value", 30))
# sample data frame, values from 1-4
head(efc[, 6:10])
# dichtomized values (1 to 2 = 0, 3 to 4 = 1)
head(dicho(efc[, 6:10], "v", 2))
# dichtomize several variables in a list
dummy <- list(efc$c12hour, efc$e17age, efc$c160age)
dicho(dummy)
# dichotomize and set labels. requires package
# sjPlot to test
library(sjPlot)
sjp.frq(dicho(efc$e42dep,
var.label = "Dependency (dichotomized)",
val.labels = c("lower", "higher")))
Run the code above in your browser using DataLab