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%",
label_col = NA,
weight = 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$".
- label_col
Deprecated, use `label.col` instead.
- weight
If there is a survey weight, variable to use in crosstab computation.
- flip
Logical, whether to flip the coordinates. FALSE by default.
- cat.rev
Logical, whether to reverse the order of categories in the legend and in the bars. FALSE by default.
