Quick stacked bar plot
Usage
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
)
Arguments
- 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.