View source: R/which_firstNA.R
which_firstNA | R Documentation |
Introduced in v 1.6.0
which_firstNA(x)
which_lastNA(x)
x |
An atomic vector. |
The position of the first/last missing value in x
.
N <- 1e8
N <- 1e6 # for CRAN etc
x <- c(1:1e5, NA, integer(N))
bench_system_time(which.max(is.na(x))) # 123ms
bench_system_time(Position(is.na, x)) # 22ms
bench_system_time(which_firstNA(x)) # <1ms
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.