Skip to contents

Quickly inspect the distribution of your categorical variables.

Usage

inspect_balance(data, vars = NULL, fill_colour = "grey30", title = NULL, ...)

Arguments

data

A non-empty data frame or tibble containing at least one categorical variable.

vars

A character vector of categorical variable names contained in data. Default value NULL will produce plots for every categorical variable in the dataset.

fill_colour

An R-supported colour or hex value used to fill the bars of the bar plot. Default value is "grey30".

title

A non-empty string for the plot title. Default value NULL results in no title being displayed.

...

Additional ggplot2 arguments passed to geom_bar layer for customizing the plot output.

Value

A ggplot2 object with bar plot(s) for each specified categorical variable.

Details

inspect_balance uses ggplot2 to produce bar plots visualizing the distribution of categorical variables. Any valid arguments that can be passed to a geom_bar layer in ggplot2 may also be passed to inspect_balance to modify plot outputs.

Examples

# Basic usage
inspect_balance(iris)


# Advanced usage
# Specify the variable to inspect and modify the plot appearance
inspect_balance(data = iris,
                vars = c("Species"),
                fill_colour = "blue",
                title = "Class balance of Species")