| plot_bar | R Documentation |
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,
...
)
data |
A data frame. |
x |
Column name for the x-axis (quoted or unquoted). |
y |
Column name for the y-axis (quoted or unquoted). |
fill |
Optional character scalar. Column name to map to fill (grouping). |
direction |
Plot direction: "vertical" or "horizontal". Default: "vertical". |
sort |
Logical. Whether to sort bars based on y values. Default: FALSE. |
sort_by |
Optional. If |
sort_dir |
Sorting direction: "asc" or "desc". Default: "asc". |
width |
Numeric. Bar width. Default: 0.7. |
... |
Additional args passed to |
A ggplot object.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.