Displaying 1 result from an estimated 1 matches for "aamin1".
Did you mean:
aamine
2008 Nov 15
0
min of array
...oping over each row/column. In this case the
loop method was faster than my apply (which probably means I wasn't
using apply in the best way). Then I found that pmin was much faster.
Here is some example code:
nr <- 300
nc <- 300
aa <- array(rnorm(nr*nc*6),c(nr,nr,6))
system.time(aamin1 <- apply(aa,c(1,2),min))
system.time({
aamin2 <- matrix(0,nr,nc)
for(i in 1:nr)
for(j in 1:nc)
aamin2[i,j] <- min(aa[i,j,])
})
system.time(aamin3 <-
pmin(aa[,,1],aa[,,2],aa[,,3],aa[,,4],aa[,,5],aa[,,6]))
I have three questions:
1) is there a better...