Learn R Programming

sjPlot (version 1.7)

group_labels: Create labels for recoded groups

Description

Creates the related labels for the grouped variable created by the group_var function.

Usage

group_labels(var, groupsize = 5, rightInterval = FALSE,
  autoGroupCount = 30)

Arguments

Value

A string vector containing labels based on the grouped counts of var, formatted as "from lower bound to upper bound", e.g. "10-19" "20-29" "30-39" etc. See example below.

See Also

group_var

Examples

Run this code
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)
efc.val <- get_val_labels(efc)
efc.var <- get_var_labels(efc)
sjp.frq(efc$e17age,
        title = efc.var[['e17age']],
        type = "h",
        showValueLabels = FALSE)

# bar plot with EUROFAMCARE sample dataset
# grouped variable
data(efc)
efc.val <- get_val_labels(efc)
efc.var <- get_var_labels(efc)
ageGrp <- group_var(efc$e17age)
ageGrpLab <- group_labels(efc$e17age)
sjp.frq(ageGrp,
        title = efc.var[['e17age']],
        axisLabels.x = ageGrpLab)

Run the code above in your browser using DataLab