Learn R Programming

bit (version 4.5.0)

firstNA: Position of first NA

Description

This is substantially faster than which.max(is.na(x))

Usage

firstNA(x)

Value

a reversed vector

Arguments

x

an R vector

See Also

which.max, is.na, anyNA, anyDuplicated, bit_anyDuplicated

Examples

Run this code
x <- c(FALSE,NA,TRUE)
firstNA(x)
reverse_vector(x)
if (FALSE) {
x <- 1:1e7
system.time(rev(x))
system.time(reverse_vector(x))
}

Run the code above in your browser using DataLab