Learn R Programming

lares (version 5.2.13)

missingness: Calculate and Visualize Missingness

Description

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)

Value

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

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?

See Also

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

Other Missing Values: impute()

Examples

Run this code
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)

# Visual results

missingness(df, plot = TRUE)

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

Run the code above in your browser using DataLab