Learn R Programming

sjPlot (version 1.7)

group_var: Recode count variables into grouped factors

Description

Recode count variables into grouped factors.

Usage

group_var(var, groupsize = 5, asNumeric = TRUE, rightInterval = FALSE,
  autoGroupCount = 30)

Arguments

Value

A grouped variable, either as numeric or as factor (see paramter asNumeric).

See Also

group_labels

Examples

Run this code
age <- abs(round(rnorm(100, 65, 20)))
age.grp <- group_var(age, 10)
hist(age)
hist(age.grp)

# 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