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)
var.cnt
is grouped into the categories represented by var.grp
.bar.pos = "stack"
). May be abbreviated.NULL
, so no weights are used.var.grp
into the factors of intr.var
, so that each category of var.grp
is subgrouped into intr.var
's categories. Only applies when
type = "boxplot"
or type = "violin"
.title = ""
, no title is printed.weight.by
is specified,
e.g. title.wtd.suffix=" (weighted)"
. Default is NULL
, so
title will not have a suffix when cases are weighted.axis.labels
. Only applies, when using box or violin plots
(i.e. type = "boxplot"
or "violin"
) and intr.var
is not NULL
.sjp.grpfrq
.TRUE
, adds total number of cases for each
group or category to the labels.TRUE
(default), percentage values are plotted to each bar
If FALSE
, percentage values are removed.TRUE
, the count within each group is added
to the category labels (e.g. "Cat 1 (n=87)"
). Default value is FALSE
.TRUE
, and depending on plot type and
function, a legend is added to the plot.TRUE
, NA
's (missing values)
are added to the output.TRUE
(default), a summary with chi-squared
statistics (see chisq.test
), Cramer's V or Phi-value etc.
is shown. If a cell contains expected values lower than five (or lower than 10
if df is 1), the Fisher's excact test (see fisher.test
) is
computed instead of chi-squared test. If the table's matrix is larger
than 2x2, Fisher's excact test with Monte Carlo simulation is computed.NULL
, i.e. the
y-axis fits to the required range of the data.grid.breaks
'th position a major grid is being printed.TRUE
, the plot grid is expanded, i.e. there is a small margin between
axes and plotting region. Default is FALSE
.type = "violin"
. Default value is 0.15type = "violin"
or "boxplot"
.type = "line"
.TRUE
, the groups of dots in a dot-plot are highlighted
with a shaded rectangle.show.summary
is TRUE
. Default is "r"
, i.e. it's printed to the upper right corner.
Use "l"
for upper left corner.TRUE
to arrange the lay out of of multiple plots
in a grid of an integrated single plot. This argument calls
facet_wrap
or facet_grid
to arrange plots. Use plot_grid
to plot multiple plot-objects
as an arranged grid with grid.arrange
.TRUE
, the x and y axis are swapped.hjust
and vjust
).vjust
aesthetics from
ggplot2
: "left", "center", "right", "bottom", "middle", "top" and
new options like "inward" and "outward", which align text towards and
away from the center of the plot respectively.vjust
aesthetics from
ggplot2
: "left", "center", "right", "bottom", "middle", "top" and
new options like "inward" and "outward", which align text towards and
away from the center of the plot respectively.TRUE
(default), plots the results as graph. Use FALSE
if you don't
want to plot any graphs. In either case, the ggplot-object will be returned as value.plot
) as well as the data frame that
was used for setting up the ggplot-object (df
).
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 color brewer palette.
Following options are valid for the geom.colors
argument:
"gs"
, a greyscale will be used.
geom.colors
is any valid color brewer palette name, the related palette will be used. Use display.brewer.all
to view all available palette names.
geom.colors = c("#f00000", "#00ff00")
).
# 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