num_na {timeplyr} | R Documentation |
Fast number of missing values
Description
A faster and more efficient alternative to sum(is.na(x))
.
Long vectors, i.e vectors with length >= 2^31 are also supported.
Usage
num_na(x)
Arguments
x |
A vector. |
Value
Number of NA
values.
Examples
library(timeplyr)
library(bench)
flights <- nycflights13::flights
# num_na is more efficient than using `sum(is.na())`
mark(vapply(flights, num_na, integer(1)),
vapply(flights, function(x) sum(is.na(x)), integer(1)),
iterations = 10)
[Package timeplyr version 0.5.0 Index]