search for: which1

Displaying 1 result from an estimated 1 matches for "which1".

Did you mean: which
2008 Jul 11
1
Suggestion: 20% speed up of which() with two-character mod
...ent to 'which' is not logical") wh <- seq_along(x)[x & !is.na(x)] m <- length(wh) dl <- dim(x) if (is.null(dl) || !arr.ind) { names(wh) <- names(x)[wh] } ... wh; } That's all. BENCHMARKING: # To measure both in same environment which1 <- base::which; environment(which1) <- globalenv(); # Needed? N <- 1e6; set.seed(0xbeef); x <- sample(c(TRUE, FALSE), size=N, replace=TRUE); names(x) <- seq_along(x); B <- 10; t1 <- system.time({ for (bb in 1:B) idxs1 <- which1(x); }); t2 <- system.time({ for (bb in 1:B...