[R] which() vs. just logical selection in df

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Thu Oct 15 00:42:40 CEST 2020


Inline.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Oct 14, 2020 at 3:23 PM 1/k^c <kchamberln using gmail.com> wrote:

Is which() invoking c-level code by chance, making it slightly faster
> on average?
>

You do not need to ask such questions. R is open source, so just look!

> which
function (x, arr.ind = FALSE, useNames = TRUE)
{
    wh <- .Internal(which(x))   ## C code
    if (arr.ind && !is.null(d <- dim(x)))
        arrayInd(wh, d, dimnames(x), useNames = useNames)
    else wh
}
<bytecode: 0x7fcdba0b8e80>
<environment: namespace:base>

	[[alternative HTML version deleted]]



More information about the R-help mailing list