| plot_bar | R Documentation |
Draw a simple bar chart from a two‑column data.frame: first column as categories (x), second as values.
plot_bar(data, label_x = "", label_y = "", colors = NULL, alpha = 1)
data |
two‑column data.frame: category in the first column, numeric values in the second |
label_x |
x‑axis label |
label_y |
y‑axis label |
colors |
optional fill color (single value) |
alpha |
bar transparency (0–1) |
If colors is provided, a constant fill is used; otherwise ggplot2's default palette applies.
alpha controls bar transparency. The first column is coerced to factor when needed.
returns a ggplot2::ggplot graphic
#summarizing iris dataset
data <- iris |> dplyr::group_by(Species) |>
dplyr::summarize(Sepal.Length=mean(Sepal.Length))
head(data)
# plotting data
grf <- plot_bar(data, colors="blue")
plot(grf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.