Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

isNA

Check if values are R NA symbol or any one of the na.strings elements


Description

A value vector in the key will generally be a character vector. This utility is used to check if the characters are either R missing or values in a list of characters that represent missings.

Usage

isNA(x, na.strings = c("\\.", "", "\\s+", "N/A"))

Arguments

x

Input data vector

na.strings

Vector of string values to be considered as missing. Defaults will match values that are equal to ., empty string, any number of white space elements, or charcter string N/A. We do not include 'NA' by default because some projects use NA to mean "not appropriate".

Value

Logical vector, TRUE if a value is either NA or in na.strings.

Examples

x1 <- c("TRUE", "FALSE", FALSE, TRUE, NA, "NA", ".", "N/A", " ", "")
x1na <- kutils:::isNA(x1)
cbind(x1, x1na)

kutils

Project Management Tools

v1.70
GPL-2
Authors
Paul Johnson [aut, cre], Benjamin Kite [aut], Charles Redmon [aut], Jared Harpole [ctb], Kenna Whitley [ctb], Po-Yi Chen [ctb], Shadi Pirhosseinloo [ctb]
Initial release
2020-04-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.