Re: [R] Efficient nested loops

2010-10-21 Thread David Winsemius
On Oct 21, 2010, at 8:39 AM, Petr PIKAL wrote: Hi fjsan...@gmail.com napsal dne 21.10.2010 12:44:30: Hi Petr, thanks for your help. My array has four dimensions. My problem is the next: library(survival) initial <- array(rnorm(120),c(40,30,20,50)) final <- array(0, dim=c(dim(initial)[

Re: [R] Efficient nested loops

2010-10-21 Thread David Winsemius
On Oct 21, 2010, at 4:40 AM, Francisco Javier Santos Alamillos wrote: Dear R community, I am working with huge arrays, so I spend a lot of time computing. This is my code: for (x in 1:dim(variable)[1]){ for (y in 1:dim(variable)[2]){ for (z in 1:dim(variable)[3]){ resu

Re: [R] Efficient nested loops

2010-10-21 Thread Petr PIKAL
Hi fjsan...@gmail.com napsal dne 21.10.2010 12:44:30: > Hi Petr, thanks for your help. > > My array has four dimensions. My problem is the next: > > library(survival) > initial <- array(rnorm(120),c(40,30,20,50)) > final <- array(0, dim=c(dim(initial)[1],dim(initial)[2],dim(initial)[3])) >

[R] Efficient nested loops

2010-10-21 Thread Francisco Javier Santos Alamillos
Dear R community, I am working with huge arrays, so I spend a lot of time computing. This is my code: for (x in 1:dim(variable)[1]){ for (y in 1:dim(variable)[2]){ for (z in 1:dim(variable)[3]){ result <- max(variable[x,y,z,]) } } } Is there a more efficient p