Omit Observations with NA, NaN, Inf and -Inf Values

Share:

Description

Omits observations with values which a not regular (=Not a Regular Value) when object is a vector, a factor, a data.frame or a matrix.

Usage

1

Arguments

x

Vector, data.frame or matrix

Details

Irregular values are defined as NA, NaN, Inf and -Inf Values in numerics and NA in factors and characters.

Value

Returns objects of class vector, factor, data.frame or matrix in the same way as na.omit does. Returns all other objects unchanged and prints a warning.

Author(s)

Rene Locher

See Also

na.omit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
M <- matrix(c(NA,1:7,NA),nrow=3)
M
NaRV.omit(M)

DF <- iris[sample(1:nrow(iris),12),]
DF[1,1] <- NA
DF[10,5] <- NA
row.names(DF) <- 1:12
DF
NaRV.omit(DF)

NaRV.omit(c(NA,1:10,NA))

fac <- factor(c(NA,sample(c(1:9))))
NaRV.omit(fac)

fac <- factor(c(NA,sample(c(1:9))),exclude=NULL)
fac
NaRV.omit(fac)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.