Plot frequencies of (count) variables

# ---------------
# boxplot
# ---------------
sjp.frq(ChickWeight$weight, type = "box")

plot of chunk sjp.frq

# ---------------
# histogram
# ---------------
sjp.frq(discoveries, type = "hist", showMeanIntercept = TRUE)

plot of chunk sjp.frq

# histogram with minimal theme and w/o labels
sjp.frq(discoveries, type = "hist",
        showMeanIntercept = TRUE,
        showValueLabels = FALSE)

plot of chunk sjp.frq

# ---------------
# violin plot
# ---------------
sjp.frq(ChickWeight$weight, type = "v")

plot of chunk sjp.frq

# ---------------
# bar plot
# ---------------
sjp.frq(ChickWeight$Diet)

plot of chunk sjp.frq

# ---------------
# bar plot with EUROFAMCARE sample dataset
# dataset was importet from an SPSS-file, using:
# efc <- sjmisc::read_spss("efc.sav", enc = "UTF-8")
# ---------------
library(sjmisc)
data(efc)
efc.val <- get_labels(efc)
efc.var <- get_label(efc)
# you may use sjp.setTheme here to change axis textangle
sjp.frq(as.factor(efc$e15relat),
        title = efc.var[['e15relat']],
        axisLabels.x = efc.val['e15relat'])

plot of chunk sjp.frq

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

plot of chunk sjp.frq

# ---------------
# box plots with interaction variable
# the following example is equal to the function call
# sjp.grpfrq(efc$e17age, efc$e16sex, type = "box")
# ---------------
sjp.frq(efc$e17age,
        title = paste(efc.var[['e17age']],
                      "by",
                      efc.var[['e16sex']]),
        interactionVar = efc$e16sex,
        interactionVarLabels = efc.val['e16sex'],
        type = "box")

plot of chunk sjp.frq

# -------------------------------------------------
# auto-detection of value labels and variable names
# -------------------------------------------------
# negative impact scale, ranging from 7-28, assuming that
# variable scale (lowest value) starts with 1
sjp.frq(efc$neg_c_7, startAxisAt = 1)

plot of chunk sjp.frq

# negative impact scale, ranging from 7-28, using
# automatic detection of start index of x-axis
sjp.frq(efc$neg_c_7)

plot of chunk sjp.frq

# -------------------------------------------------
# plotting confidence intervals
# -------------------------------------------------
sjp.frq(efc$e15relat,
        type = "dots",
        showCI = TRUE,
        sort.frq = "desc",
        coord.flip = TRUE)
## Warning: Removed 1 rows containing missing values (geom_text).
## Warning: Removed 4 rows containing missing values (geom_path).

plot of chunk sjp.frq

# -------------------------------------------------
# Simulate ggplot-default histogram, using "hist.skipZeros"
# and adjusted "geom.size".
# -------------------------------------------------
sjp.frq(efc$c160age,
        type = "h",
        hist.skipZeros = TRUE,
        geom.size = 1)

plot of chunk sjp.frq