age <- abs(round(rnorm(100, 65, 20)))
age.grp <- group_var(age, 10)
hist(age)
hist(age.grp)
age.grpvar <- group_labels(age, 10)
table(age.grp)
print(age.grpvar)
# histogram with EUROFAMCARE sample dataset
# variable not grouped
data(efc)
library(sjPlot)
sjp.frq(efc$e17age,
title = get_var_labels(efc$e17age),
type = "h",
showValueLabels = FALSE)
# bar plot with EUROFAMCARE sample dataset
# grouped variable
data(efc)
ageGrp <- group_var(efc$e17age)
ageGrpLab <- group_labels(efc$e17age)
library(sjPlot)
sjp.frq(ageGrp,
title = get_var_labels(efc$e17age),
axisLabels.x = ageGrpLab)
Run the code above in your browser using DataLab