This function simply wraps around ggplot2::geom_col()
to take a dataframe
and categorical variable to return a custom barplot ggplot
object. The bars
are arranged in descending order and are limited to the 8 most frequent
values.
explore_plot(data, var, nbar = 8, palette = "Dark2", na.rm = TRUE)
The data frame to explore.
A variable to plot.
The number of bars to plot. Always shows most common values.
The color palette passed to [ggplot2::scale_fill_brewer().
logical: Should NA
values of var
be removed?
A ggplot
barplot object. Can then be combined with other ggplot
layers with +
to customize.
explore_plot(iris, Species)