Investigate missingness

sum_NA(x)

sum_NaN(x)

sum_blank(x)

Arguments

x

a vector with multiple elements

Value

The number of non-elements so defined

Details

These functions return the number of NA, NaN, or blank values in a vector. Such information can serve as a diagnostic or used outright, e.g. in longitudinal settings. If you are dealing with singletons, you should just use the underlying function, e.g. is.na. For total blank values, the stringi package is required.

For more in this realm, I suggest you visit naniar.

Examples

library(tidyext) sum_blank(c(' ', '', 'c', 'd'))
#> [1] 2
sum_NA(c(NA, '', 'c', NA))
#> [1] 2
sum_NaN(c(1:3, NA, NaN))
#> [1] 1
sum_NA(1:4)
#> [1] 0