Plots a set of categorical variables with same response categories as a single graph.
Usage
stem_plot_battery(
data,
items,
weight = NULL,
order_by = NULL,
geom_args = list(position = "stack"),
label_args = list(position = ggplot2::position_stack(vjust = 0.5), color =
label_text_color),
label_scale = 100,
label_text_color = "black",
label_hide = 0.05,
item_label = TRUE,
group_size = "none",
scale_y = ggplot2::scale_y_continuous(labels = scales::percent_format(accuracy = 1,
suffix = " %")),
coord_flip = TRUE,
palette = "div1",
legend_rows = 1,
legend_byrow = TRUE,
item_reverse = TRUE,
group_reverse = TRUE,
...
)
Arguments
- data
Dataframe including item (and group) variables
- items
Plotted items. Can be selected using Tidyselect's selection helpers.
- weight
Optional; survey weights
- order_by
Vector of response categories to order items by, e.g.
c("Definitely Agree", "Rather Agree")
.- geom_args
Arguments for the geom function like size, color, etc.
- label_args
Arguments for the labels function like vjust, postion, etc.
- label_scale
Multiplicative scale of geom labels.
100
multiple the values by 100.- label_text_color
Color of text labels. Default is
black
.- label_hide
Hides geom labels with values smaller than this threshold. Defaults to 0.05.
- item_label
If
TRUE
, item labels are used instead of names (all items must have a label).- group_size
Should the group size be included in the group legend? Either
n
(absolute frequency),prop
(proportions) ornone
(nothing).- scale_y
Format y axis using
ggplot2::scale_y_continuous()
- coord_flip
If
TRUE
, switches x and y axes.- palette
Stem palette to be used in the plot. See
scale_color_stem()
andscale_fill_stem()
for details.- legend_rows
Number of rows in legend
- legend_byrow
Shoul legend be filled by rows? (FALSE to fill by columns)
- item_reverse
Should the order of item categories be reversed? Defaults to
TRUE
- group_reverse
Should the order of group categories be reversed? Defaults to
TRUE
- ...
Other arguments passed to
stem_plot()