Skip to contents

This function returns the row number of any row in a data frame or matrix that has at least one NA. This is the same as which(!complete.cases(x)).

Usage

naRows(x, inf = FALSE, inverse = FALSE)

Arguments

x

Data frame or matrix.

inf

Logical, if TRUE then also return row numbers of rows in which at least one element is Inf or -Inf. The default is FALSE.

inverse

Logical, if TRUE then return row numbers of rows that do not have NAs (and possibly Inf or -Inf). The default is FALSE.

Value

Integer vector.

Examples

x <- data.frame(a=1:5, b=c(1, 2, NA, 4, 5), c=c('a', 'b', 'c', 'd', NA))
naRows(x)
#> [1] 3 5