na_count() is a way to display the count and frequency of NA in data. It can be slow over large datasets.

na_count(data, sort = TRUE)

Arguments

data

a data frame

sort

If TRUE, sort rows by descending na_percent. If FALSE, keep column order from the input.

Value

a long-format tibble

Acknowledgment

I learned this way of exploring data though the excellent webinar taught by Emily Robinson.

Examples

# \donttest{
na_data <- data.frame(c1 = c(1, NA), c2 = c(NA, NA))
na_data %>% na_count()
#> # A tibble: 2 × 3
#>   variables na_count na_percent
#>   <chr>        <int>      <dbl>
#> 1 c2               2        100
#> 2 c1               1         50
# }