Learn R Programming

sjPlot (version 2.0.0)

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(var.cnt, var.grp, type = c("bar", "dot", "line", "boxplot",
  "violin"), bar.pos = c("dodge", "stack"), weight.by = NULL,
  intr.var = NULL, title = "", title.wtd.suffix = NULL,
  legend.title = NULL, axis.titles = NULL, axis.labels = NULL,
  legend.labels = NULL, intr.var.labels = NULL, wrap.title = 50,
  wrap.labels = 15, wrap.legend.title = 20, wrap.legend.labels = 20,
  geom.size = NULL, geom.spacing = 0.15, geom.colors = "Paired",
  show.values = TRUE, show.n = TRUE, show.prc = TRUE,
  show.axis.values = TRUE, show.grpcnt = FALSE, show.legend = TRUE,
  show.na = FALSE, show.summary = FALSE, auto.group = NULL, ylim = NULL,
  grid.breaks = NULL, expand.grid = FALSE, inner.box.width = 0.15,
  inner.box.dotsize = 3, smooth.lines = FALSE, emph.dots = TRUE,
  summary.pos = "r", facet.grid = FALSE, coord.flip = FALSE,
  y.offset = NULL, vjust = "bottom", hjust = "center", prnt.plot = 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).

Details

geom.colors may be a character vector of color values in hex-format, valid color value names (see demo("colors") or a name of a http://colorbrewer2.org{color brewer} palette. Following options are valid for the geom.colors argument:
  • If not specified, a default color brewer palette will be used, which is suitable for the plot style (i.e. diverging for likert scales, qualitative for grouped bars etc.).
  • If"gs", a greyscale will be used.
  • Ifgeom.colorsis any valid color brewer palette name, the related palette will be used. Usedisplay.brewer.allto view all available palette names.
  • Else specify own color values or names as vector (e.g.geom.colors = c("#f00000", "#00ff00")).

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, show.values = FALSE)

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

# grouped bars
sjp.grpfrq(efc$e42dep, efc$e16sex, title = NULL)

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

# Grouped bar plot
sjp.grpfrq(efc$neg_c_7, efc$e42dep, show.values = FALSE)

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

Run the code above in your browser using DataLab