View source: R/missing_pattern_plot.r
missing_pattern_plot | R Documentation |
This function plots the missingness patterns and (if desired) also their their frequencies in the data frame.
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)
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". |
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.