Quickly inspect the missing values in a dataset by producing a bar plot.
Usage
inspect_missing(
data,
vars = NULL,
na_colour = "red",
fill_colour = "grey30",
title = NULL,
...
)
Arguments
- data
A non-empty data frame or tibble.
- vars
A character vector of column names to inspect. Default value
NULL
will produce plots for every variable in the data.- na_colour
An R-supported colour or hex value to indicate missing values. Default value is "red".
- fill_colour
An R-supported colour or hex value to indicate non-missing values. 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 togeom_bar
layer to modify plot outputs.
Value
A ggplot2 object (a bar plot) showing the proportion of missingness for the specified variables.
Details
inspect_missing
uses ggplot2
to produce a bar plot representing the proportion of missing and non-missing values for each column in the dataset. Any valid arguments that may be passed to a geom_bar
layer in ggplot2
may also be passed to inspect_missing
via ...
to customize the plot appearance.
Examples
# Basic usage
inspect_missing(airquality)
# Advanced usage: Manually specify variables and modify plot output
inspect_missing(data = airquality,
vars = c("Ozone", "Solar.R"),
na_colour = "green",
fill_colour = "blue",
alpha = 0.5)