Learn R Programming

relevance (version 2.1)

dropNA: drop or replace NA values

Description

dropNA returns the vector 'x', without elements that are NA or NaN or, if 'inf' is TRUE, equal to Inf or -Inf. replaceNA replaces these values by values from the second argument

Usage

dropNA(x, inf = TRUE)
replaceNA(x, na, inf = TRUE)

Value

For dropNA: Vector containing the 'real' values of 'x' only

For replaceNA: Vector with 'non-real' values replaced by the respective elements of na.

Arguments

x

vector from which the non-real values should be dropped or replaced

na

replacement or vector from which the replacing values are taken.

inf

logical: should 'Inf' and '-Inf' be considered "non-real"?

Author

Werner A. Stahel

See Also

na.omit, sumNA, ifelse

Examples

Run this code
dd <- c(1, NA, 0/0, 4, -1/0, 6)
dropNA(dd)
na.omit(dd)

replaceNA(dd, 99)
replaceNA(dd, 100+1:6)

Run the code above in your browser using DataLab