Create a bar chart from a data frame with optional grouping (fill),
vertical/horizontal orientation, and sorting by values.
plot_bar(
data,
x,
y,
fill = NULL,
direction = c("vertical", "horizontal"),
sort = FALSE,
sort_by = NULL,
sort_dir = c("asc", "desc"),
width = 0.7,
...
)A ggplot object.
A data frame.
Column name for the x-axis (quoted or unquoted).
Column name for the y-axis (quoted or unquoted).
Optional character scalar. Column name to map to fill (grouping).
Plot direction: "vertical" or "horizontal". Default: "vertical".
Logical. Whether to sort bars based on y values. Default: FALSE.
Optional. If fill is set and sort = TRUE, choose which level
of fill is used for sorting.
Sorting direction: "asc" or "desc". Default: "asc".
Numeric. Bar width. Default: 0.7.
Additional args passed to ggplot2::geom_bar(), e.g. alpha, color.