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)
Run the code above in your browser using DataLab