glimpse_na: Show the number of (remaining) missing values.

View source: R/utils.R

glimpse_naR Documentation

Show the number of (remaining) missing values.

Description

Quick indication of the amount and location of missing values. The function uses na_status to print the missing values, but returns the original x (invisibly) and therefore can be used in an imputation pipeline to peek at the NA's status.

Usage

glimpse_na(x, show_only_missing = TRUE, ...)

lhs %?>% rhs

Arguments

x

an R object caryying data (e.g. data.frame)

show_only_missing

if TRUE only columns with NA's will be printed.

...

arguments passed to na_status.

lhs

left hand side of pipe

rhs

right hand side of pipe

Details

glimpse_na is especially helpful when interactively adding imputation methods. glimpse_na is named after glimpse in dplyr.

Operator %?>% is syntactic sugar: it inserts a glimpse_na in the pipe.

Examples



   
irisNA <- iris
irisNA[1:3,1] <- irisNA[3:7,2] <- NA

# How many NA's?
na_status(irisNA)

# add an imputation method one at a time
iris_imputed <-
  irisNA |> 
  glimpse_na() # same as above

# ok, glimpse_na says "Sepal.Width" has NA's
# fix that:

iris_imputed <-
  irisNA |> 
  impute_const(Sepal.Width ~ 7) |> 
  glimpse_na() # end NA

# Sepal.Length is having NA's

iris_imputed <-
  irisNA |> 
  impute_const(Sepal.Width ~ 7) |>
  impute_cart(Sepal.Length ~ .) |>  
  glimpse_na() # end NA

# in an existing imputation pipeline we can peek with
# glimpse_na or %?>%

iris_imputed <-
  irisNA |> 
  glimpse_na() |>     # shows the begin NA
  impute_const(Sepal.Width ~ 7) |> 
  glimpse_na() |>     # after 1 imputation
  impute_cart(Sepal.Length ~ .) |>  
  glimpse_na()         # end NA
  
# or
iris_imputed <-
  irisNA %?>% 
  impute_const(Sepal.Width ~ 7) %?>% 
  impute_cart(Sepal.Length ~ .)
  
na_status(iris_imputed)  


simputation documentation built on June 16, 2022, 5:10 p.m.