missing_pattern_plot: Missingness pattern plot

View source: R/missing_pattern_plot.r

missing_pattern_plotR Documentation

Missingness pattern plot

Description

This function plots the missingness patterns and (if desired) also their their frequencies in the data frame.

Usage

missing_pattern_plot(data, colors = c("#2F6FAF", "lightblue"),
  titles = c("A", "B"), var_labels = FALSE, frequency = TRUE,
  percent = FALSE, ratio = c(2.5, 1), nrow = 1)

Arguments

data

The data frame that should be evaluated.

colors

Colors to be used in the plot.

titles

Both plots can be named individually. By default, they are simply labelled "A" and "B".

var_labels

A logical value indicating whether variable names should be plotted (if many variables are in the data frame, setting this to TRUE can be messy).

frequency

A logical value indicating whether the frequency of the missingness pattens should be plotted to.

percent

A logical value indicating whether the share of cases that have a particular missingness pattern should be plotted into the frequency table (still beta, doesn't look very nice..., simply helps to understand the data)

ratio

Vector specifying the size of both plots in comparison to one another.

nrow

Should the plots be printed underneath or next to each other? Defaults to "next to each other".

Value

A gtable which consists by default of two plots: (A) An overview of all existing missingness patterns in the data frame, (B) a frequency table representing how often the particular missingness patterns can be found in the data frame.

Examples

d <- mtcars
d[4,3] <- NA # Create missing to illustrate function

missing_pattern_plot(d)

# Add variable names and plot only patterns
missing_pattern_plot(d, var_labels = T, frequency = F)

masurp/pmmisc documentation built on May 3, 2024, 7:13 p.m.