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

Description Usage Arguments Value Examples

View source: R/variableKey.R

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

1
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

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

Example output

      x1      x1na   
 [1,] "TRUE"  "FALSE"
 [2,] "FALSE" "FALSE"
 [3,] "FALSE" "FALSE"
 [4,] "TRUE"  "FALSE"
 [5,] NA      "TRUE" 
 [6,] "NA"    "FALSE"
 [7,] "."     "TRUE" 
 [8,] "N/A"   "TRUE" 
 [9,] " "     "TRUE" 
[10,] ""      "TRUE" 

kutils documentation built on April 30, 2020, 1:05 a.m.