stacked_bar | R Documentation |
Quick stacked bar plot
stacked_bar(
variable,
group,
sort.cat = 1,
colors = NA,
include.na = FALSE,
labs = TRUE,
label.col = NA,
format.label = "2%",
weight = NA,
label_col = NA,
flip = F,
cat.rev = F
)
variable |
Variable to be plotted. |
group |
Grouping variable to cross-tabulate and compute. |
sort.cat |
Category to sort the stacked chart. |
colors |
Vector of colors distinguishing groups. |
include.na |
Logical. Should NAs be a separate level or should they be excluded? FALSE by default. |
labs |
Logical. Should percents labels be added to the plot. TRUE by default. |
label.col |
In case labels are added, vector of labels colors. |
format.label |
Character of one digit standing for decimal places and one symbol added in the end, for example "1%" would result in "99.9%" whereas "2$" would lead to "99.99$". |
weight |
If there is a survey weight, variable to use in crosstab computation. |
label_col |
Same as label.col, saved for legacy. |
Computes proportions cross-table and plots it in a nice way. ggplot-based, so '+theme()' and other arguments can be added directly to transform the plot.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.