
Last chance! 50% off unlimited learning
Sale ends in
Plot bar chart for each discrete feature, based on either frequency or another continuous feature.
plot_bar(
data,
with = NULL,
by = NULL,
by_position = "fill",
maxcat = 50,
order_bar = TRUE,
binary_as_factor = TRUE,
title = NULL,
ggtheme = theme_gray(),
theme_config = list(),
nrow = 3L,
ncol = 3L,
parallel = FALSE
)
invisibly return the named list of ggplot objects
input data
name of continuous feature to be summed. Default is NULL
, i.e., frequency.
discrete feature name to be broken down by.
position argument in geom_bar if by
is supplied. Default is "fill"
.
maximum categories allowed for each feature. Default is 50.
logical, indicating if bars should be ordered. Default is TRUE
.
treat binary as categorical? Default is TRUE
.
plot title
complete ggplot2 themes. Default is theme_gray.
a list of configurations to be passed to theme
number of rows per page. Default is 3.
number of columns per page. Default is 3.
enable parallel? Default is FALSE
.
If a discrete feature contains more categories than maxcat
specifies, it will not be passed to the plotting function.
# Plot bar charts for diamonds dataset
library(ggplot2)
plot_bar(diamonds)
plot_bar(diamonds, maxcat = 5)
# Plot bar charts with `price`
plot_bar(diamonds, with = "price")
# Plot bar charts by `cut`
plot_bar(diamonds, by = "cut")
plot_bar(diamonds, by = "cut", by_position = "dodge")
Run the code above in your browser using DataLab