View source: R/functions_special_plots.R
draw_freq_panel | R Documentation |
Draws a panel of stacked or dodged bar plots with frequencies or counts for the given categorical variables. Works best, when the variables share the same levels.
draw_freq_panel(
data,
variables,
split_factor = NULL,
rm_na = TRUE,
scale = c("percent", "fraction", "count"),
form = c("stack", "dodge"),
show_labels = FALSE,
txt_size = 2.75,
geom_label = TRUE,
signif_digits = 2,
alpha = 1,
dodge_w = 0.9,
plot_title = NULL,
plot_subtitle = NULL,
plot_tag = NULL,
x_lab = "% of cohort",
y_lab = split_factor,
cust_theme = ggplot2::theme_classic(),
...
)
data |
a data frame. |
variables |
names of the variables to plot, they need to be factors. |
split_factor |
name of the splitting variable. |
rm_na |
logical, should missing observations be removed prior to plotting? If FALSE, |
scale |
statistic to be plotted: percent (default), fraction or counts of observations for each variable level. |
form |
form of the bar plot: stacked bars (default) or dodged bars. |
show_labels |
logical, should the data bars be labeled with the percent, fraction or count value? |
txt_size |
size of the label text, ignored if show_labels is FALSE. |
signif_digits |
significant digits to be shown in the bar labels. |
alpha |
alpha of the bar or distribution width ribbon. |
dodge_w |
dodge width. |
plot_title |
plot title. |
plot_subtitle |
plot subtitle. |
plot_tag |
plot tag. |
x_lab |
x axis title. |
y_lab |
Y axis title. |
cust_theme |
custom ggplot theme. |
... |
additional arguments passed to |
split |
name of the splitting variable (optional). If provided, the panel will be faceted by the variables and the split_factor presented in the Y axis. |
geom_labe |
logical, should the bar label be presented as a geom_label? If FALSE, plain text is displayed. |
a ggplot object.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.