Learn R Programming

MAPCtools (version 0.1.0)

plot_missing_data: Plot Missing Group Combinations

Description

Creates a tile plot highlighting combinations of grouping variables that are expected but missing from the data. Allows for faceting.

Usage

plot_missing_data(
  data,
  x,
  y,
  stratify_by = NULL,
  for_each = NULL,
  facet_labeller = NULL,
  title = "Missing data",
  subtitle = NULL,
  x_lab = NULL,
  y_lab = NULL
)

Value

A ggplot object, or NULL if no missing combinations found.

Arguments

data

Data frame.

x

Variable in data whose values define the x-axis.

y

Variable in data whose values define the y-axis.

stratify_by

(Optional) Stratification variable. If supplied, missing data is examined separately for each leves of stratify_by, and each level gets its own panel.

for_each

(Optional) Additional stratification variable. If supplied, separate plot windows are created per level of for_each.

facet_labeller

A labeller function (e.g. labeller), or a named list where names match facet variables and values are named vectors/lists mapping levels to labels (optional).

title

Character string for the plot title. Defaults to "Missing data".

subtitle

Character string for the plot subtitle. Defaults to NULL.

x_lab

Character string for the x-axis label. Defaults to the name of x_var.

y_lab

Character string for the y-axis label. Defaults to the name of y_var.

See Also

Examples

Run this code
data("toy_data")

# Plot missing data across age and period, stratified by education, for each sex
plot_missing_data (data        = toy_data,
                   x           = period,
                   y           = age,
                   stratify_by = education,
                   for_each    = sex)


Run the code above in your browser using DataLab