which_ {cheapr} | R Documentation |
which()
Exactly the same as which()
but more memory efficient.
which_(x, invert = FALSE)
x |
A logical vector. |
invert |
If |
This implementation is similar in speed to which()
but usually more memory efficient.
An unnamed integer vector.
library(cheapr)
library(bench)
x <- sample(c(TRUE, FALSE), 1e05, TRUE)
x[sample.int(1e05, round(1e05/3))] <- NA
mark(which_(TRUE), which(TRUE))
mark(which_(FALSE), which(FALSE))
mark(which_(logical()), which(logical()))
mark(which_(x), which(x), iterations = 20)
mark(base = which(is.na(match(x, TRUE))),
collapse = collapse::whichv(x, TRUE, invert = TRUE),
cheapr = which_(x, invert = TRUE),
iterations = 20)