Learn R Programming

healthcareai (version 1.2.4)

countMissingData: Function to find proportion of NAs in each column of a dataframe or matrix

Description

Finds the proportion of NAs in each column of a dataframe or matrix. NA possibilities that are defined: NA, "NA", "NAs", "na", NaN, "NaN" , "?", "??", "nil", "NULL", " ", "", "999". User has ability to define their own NA values by using the userNAs parameter. User defined NAs will be added to the list of already defined NAs.

Usage

countMissingData(x, userNAs = NULL)

Arguments

x

A data frame or matrix

userNAs

A vector of user defined NA values.

Value

A numeric vector of the proportion of NAs in each column.

References

http://healthcareai-r.readthedocs.io

See Also

healthcareai

Examples

Run this code
# NOT RUN {
bob <- data.frame(d = c("NULL", NA, "empty", 5, "?", 'nil', "NaN", " ", 2),
                  y = c("??", ' ', "999", 999, "tom", "5", 7, 10, 2),
                  l = rep(NA, 9),
                  a = c("blank", 0, "na", "None", "none", 3, 10, 4, "what"),
                  n = c(10, 5, 8, 1, NA, "NULL", NaN, "Nas", 2),
                  new = c(1, 2, 3, 4, 5, "void", 7, 8, "what"))           
countMissingData(bob)
countMissingData(bob, userNAs = c("void", "what"))
# }

Run the code above in your browser using DataLab