Learn R Programming

DataExplorer (version 0.6.0)

plot_missing: Plot missing value profile

Description

This function returns and plots frequency of missing values for each feature.

Usage

plot_missing(data, title = NULL, ggtheme = theme_gray(),
  theme_config = list(legend.position = c("bottom")))

Arguments

data

input data

title

plot title

ggtheme

complete ggplot2 themes. The default is theme_gray.

theme_config

a list of configurations to be passed to theme.

Value

missing value information, such as frequency, percentage and suggested action.

Details

The returned object is suppressed by invisible.

To change default font family and size, you may pass base_size and base_family to ggtheme options, e.g., ggtheme = theme_gray(base_size = 15, base_family = "serif")

theme_config argument expects all inputs to be wrapped in a list object, e.g., to change the text color: theme_config = list("text" = element_text(color = "blue"))

Examples

Run this code
# NOT RUN {
# Load packages
library(data.table)

# Add missing values to iris data
dt <- data.table(iris)
for (j in 1:4) set(dt, i = sample(150, j * 30), j, value = NA_integer_)

# Plot and assign missing value information
na_profile <- plot_missing(dt)
na_profile

# Drop columns with more than 50% missing values
drop_columns(dt, as.character(na_profile[pct_missing >= 0.5][["feature"]]))
plot_missing(dt)
# }

Run the code above in your browser using DataLab