naniar package (a play on Narnia) if you haven’t already!
Missing data can be a problem for many reasons
A quick missingness check can reveal
n_miss() from naniar counts the total number of missing values across an entire datasetNA cells across every column combinedn_complete() is the complement of n_miss()
prop_miss() gives the proportion of all cells in the dataset that are missingn_miss() to count the number of missing values in a single variableNA cells in self-reported health
prop_miss() to get the proportion of missing values in a single variableNA cells in self-reported healthmiss_var_summary() gives one row per variable, with the count and percent missinggt() makes it a nicer table to read| variable | n_miss | pct_miss |
|---|---|---|
| ed | 507 | 18.6 |
| race_original | 486 | 17.8 |
| height | 55 | 2.02 |
| act_vig | 9 | 0.330 |
| srh | 4 | 0.147 |
| sex | 0 | 0 |
vis_miss(): visualizing missing data across the datasetgg_miss_fct(): missingness heatmap by groupfct = option of gg_miss_fct()
Example: percent missingness stratified by srh (self-reported health)
gg_miss_fct() is a function that produces a heatmap of missingness stratified by a factor variable. We are stratifying by self-reported health (srh) in this example

gg_miss_upset(): missingness intersections (1/2)gg_miss_upset() shows the most common combinations (sets) of missing variablesgg_miss_upset() is a function that produces an UpSet plot of missingness intersections
nsets = 10 limits the plot to the 10 largest combinations of co-missing variables, which keeps the plot readable
text.scale = 3 increases the size of the text in the plot, which makes it easier to read

gg_miss_upset(): missingness intersections (2/2)gg_miss_upset() shows the most common combinations (sets) of missing variablesgg_miss_upset() is a function that produces an UpSet plot of missingness intersections
nsets = 10 limits the plot to the 10 largest combinations of co-missing variables, which keeps the plot readable
text.scale = 3 increases the size of the text in the plot, which makes it easier to read

gg_miss_upset(): What am I taking away from this plot?
race_original and ed with 465 observations
ed missing but not race_originalrace_original missing but not ednaniar that help us summarize and visualize missingness in a dataset
n_miss() and prop_miss() give quick, high-level counts of missingness across a whole datasetmiss_var_summary() gives a tidy, sortable summary of missingness by variablevis_miss() gives a bird’s-eye view of missingness across every row and columngg_miss_fct() compares missingness rates across groupsgg_miss_upset() reveals which variables tend to be missing togetherMissing data: summarization and visualization