Skip to contents

This function lets the user calculate the percentage of NAs or missingness in a data.frame. It also plots the results if needed.

Usage

missingness(df, plot = FALSE, full = FALSE, subtitle = NA, summary = TRUE)

Arguments

df

Dataframe. Dataframe to study

plot

Boolean. Do you wish to plot results?

full

Boolean. Return all variables (or only with missings)?

subtitle

Character. Subtitle to show in plot

summary

Boolean. Show numerical summary text?

Value

data.frame with each variable, number of missing values and percentage. If plot=TRUE, a plot with the same information reflected.

See also

Other Exploratory: corr_cross(), corr_var(), crosstab(), df_str(), distr(), freqs_df(), freqs_list(), freqs_plot(), freqs(), lasso_vars(), plot_cats(), plot_df(), plot_nums(), tree_var()

Other Missing Values: impute()

Examples

Sys.unsetenv("LARES_FONT") # Temporal

# Dummy data
df <- data.frame(
  A = c(1:5),
  B = c(NA, NA, 1, 1, 1),
  C = rep(NA, 5),
  D = c(NA, LETTERS[1:4])
)

# Missing values summary
missingness(df)
#>   variable missing missingness
#> 1        C       5         100
#> 2        B       2          40
#> 3        D       1          20

# Visual results

missingness(df, plot = TRUE)


# Show all variables (including those with no missing values)
missingness(df, plot = TRUE, full = TRUE)