Skip to content
Prev 274126 / 398506 Next

high and lowest with names

which.max is even faster:

dims <- c(1000,1000)
tt <- array(rnorm(prod(dims)),dims)
# which
system.time(
replicate(100, which(tt==max(tt), arr.ind=TRUE))
)
# which.max (& arrayInd)
system.time(
replicate(100, arrayInd(which.max(tt), dims))
)

Best,
Denes