Learn R Programming

sjPlot (version 2.0.0)

sjp.frq: Plot frequencies of variables

Description

Plot frequencies of a variable as bar graph, histogram, box plot etc.

Usage

sjp.frq(var.cnt, title = "", weight.by = NULL, title.wtd.suffix = NULL,
  sort.frq = c("none", "asc", "desc"), type = c("bar", "dot", "histogram",
  "line", "density", "boxplot", "violin"), geom.size = NULL,
  geom.colors = "#336699", errorbar.color = "darkred", axis.title = NULL,
  axis.labels = NULL, xlim = NULL, ylim = NULL, wrap.title = 50,
  wrap.labels = 20, grid.breaks = NULL, expand.grid = FALSE,
  show.values = TRUE, show.n = TRUE, show.prc = TRUE,
  show.axis.values = TRUE, show.ci = FALSE, show.na = FALSE,
  show.mean = FALSE, show.mean.val = TRUE, show.sd = TRUE,
  mean.line.type = 2, mean.line.size = 0.5, inner.box.width = 0.15,
  inner.box.dotsize = 3, normal.curve = FALSE, normal.curve.color = "red",
  normal.curve.size = 0.8, normal.curve.alpha = 0.4, auto.group = NULL,
  coord.flip = FALSE, vjust = "bottom", hjust = "center",
  y.offset = NULL, 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 (mydf).

See Also

  • http://www.strengejacke.de/sjPlot/sjp.frq/{sjPlot manual: sjp.frq}
  • sjt.frq

Examples

Run this code
# boxplot
sjp.frq(ChickWeight$weight, type = "box")

# histogram
sjp.frq(discoveries, type = "hist", show.mean = TRUE)
        
# violin plot
sjp.frq(ChickWeight$weight, type = "v")

# bar plot
sjp.frq(ChickWeight$Diet)


# 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)
# you may use sjp.setTheme here to change axis textangle
sjp.frq(efc$e15relat)

# bar plot with EUROFAMCARE sample dataset
# grouped variable
ageGrp <- group_var(efc$e17age)
ageGrpLab <- group_labels(efc$e17age)
sjp.frq(ageGrp, title = get_label(efc$e17age), axis.labels = ageGrpLab)

# negative impact scale, ranging from 7-28
sjp.frq(efc$neg_c_7)

# plotting confidence intervals. expand grid and v/hjust for text labels
sjp.frq(efc$e15relat, type = "dot", show.ci = TRUE, sort.frq = "desc",
        coord.flip = TRUE, expand.grid = TRUE, vjust = "bottom", 
        hjust = "left")

# Simulate ggplot-default histogram
sjp.frq(efc$c160age, type = "h", geom.size = 3)

# histogram with overlayed normal curve
sjp.frq(efc$c160age, type = "h", show.mean = TRUE, show.mean.val = TRUE,
        normal.curve = TRUE, show.sd = TRUE, normal.curve.color = "blue",
        normal.curve.size = 3, ylim = c(0,50))

Run the code above in your browser using DataLab