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

firstNA(x)

Arguments

x

an R vector

Value

a reversed vector

Examples

x <- c(FALSE, NA, TRUE)
firstNA(x)
#> [1] 2
reverse_vector(x)
#> [1]  TRUE    NA FALSE
if (FALSE) { # \dontrun{
x <- 1:1e7
system.time(rev(x))
system.time(reverse_vector(x))
} # }