count_NA: Count the number of 'NA's

View source: R/count_NA.R

count_NAR Documentation

Count the number of NAs

Description

Count the number of NA values in a vector, matrix or data frame

Usage

count_NA(x, type = "default")

Arguments

x

a vector, matrix or data frame, in which NA values are counted

type

How to count the NA values. Possible choices:

  • "default": If x is a matrix or a data frame, the number of missing values per column is returned. If x is something else, the total number of missing values in x is returned.

  • "all": The number of all missing values in x is returned.

  • "cols": The number of missing values per column is returned.

  • "rows": The number of missing values per row is returned.

Value

The number of missing values.

Examples

count_NA(c(1, NA, 3, NA, 5, NA))
test_df <- data.frame(X1 = rep(c(1, NA), 5), X2 = c(1:9, NA))
count_NA(test_df)
count_NA(test_df, "cols") # the default
count_NA(test_df, "rows")
count_NA(test_df, "all")

torockel/missMethods documentation built on Sept. 16, 2022, 5:16 p.m.