Learn R Programming

sjPlot (version 1.9.3)

sjp.grpfrq: Plot grouped or stacked frequencies

Description

Plot grouped or stacked frequencies of variables as bar/dot, box or violin plots, or line plot.

Usage

sjp.grpfrq(varCount, varGroup, weightBy = NULL, weightByTitleString = NULL,
  interactionVar = NULL, type = "bars", geom.size = NULL,
  geom.spacing = 0.15, geom.colors = "Paired", hideLegend = FALSE,
  facet.grid = FALSE, title = "", legendTitle = NULL,
  axisLabels.x = NULL, interactionVarLabels = NULL, legendLabels = NULL,
  axisLimits.y = NULL, breakTitleAt = 50, breakLabelsAt = 15,
  breakLegendTitleAt = 20, breakLegendLabelsAt = 20, gridBreaksAt = NULL,
  barPosition = "dodge", innerBoxPlotWidth = 0.15,
  innerBoxPlotDotSize = 3, smoothLines = FALSE, expand.grid = FALSE,
  showValueLabels = TRUE, showCountValues = TRUE,
  showPercentageValues = TRUE, showAxisLabels.x = TRUE,
  showAxisLabels.y = TRUE, showPlotAnnotation = TRUE,
  showTableSummary = FALSE, showGroupCount = FALSE, tableSummaryPos = "r",
  axisTitle.x = "", axisTitle.y = "", autoGroupAt = NULL,
  coord.flip = FALSE, vjust = "bottom", hjust = "center",
  y.offset = NULL, na.rm = TRUE, printPlot = TRUE)

Arguments

Value

(Insisibily) returns the ggplot-object with the complete plot (plot) as well as the data frame that was used for setting up the ggplot-object (df).

See Also

http://www.strengejacke.de/sjPlot/sjp.grpfrq/{sjPlot manual: sjp.grpfrq}

Examples

Run this code
# histrogram with EUROFAMCARE sample dataset
library(sjmisc)
data(efc)
sjp.grpfrq(efc$e17age,
           efc$e16sex,
           showValueLabels = FALSE)

# boxplot
sjp.grpfrq(efc$e17age, 
           efc$e42dep, 
           type = "box")

# -------------------------------------------------
# auto-detection of value labels and variable names
# -------------------------------------------------
# grouped bars using necessary y-limit            
sjp.grpfrq(efc$e42dep, 
           efc$e16sex, 
           title = NULL)

# box plots with interaction variable            
sjp.grpfrq(efc$e17age,
           efc$e42dep,
           interactionVar = efc$e16sex,
           type = "box")

# Grouped bar plot ranging from 7 to 28
sjp.grpfrq(efc$neg_c_7, 
           efc$e42dep, 
           showValueLabels = FALSE)

# same data as line plot
sjp.grpfrq(efc$neg_c_7, 
           efc$e42dep, 
           type = "lines")

Run the code above in your browser using DataLab