Learn R Programming

rccmisc (version 0.3.7)

specify_missing: Specify missing values for a vector

Description

Change specified values to NA

Usage

specify_missing(x, ..., default_missing = c("", NA, "blanks"))

Arguments

x
vector
...
values that should be changed to NA if found in x
default_missing
a vector with additional default values to change to NA. These are treated the same as ... but are added by default if not removed. A special value "blank" can be used to indicate all empty strings (all characters matching [:blank:], see regex).

Value

x itself but with specified values set to NA.

Examples

Run this code
x <- sample(100)
x[sample(100, 10)] <- 999
specify_missing(x, 999)

Run the code above in your browser using DataLab