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]){
           result <- max(variable[x,y,z,])
       }
   }
}

Is there a more efficient procedure to do this task?

Are you sure this is a proper specification of the "task"?. You have overwritten the "result" with max(.) multiple times (the product of the dimensions) and only have at the end that effort just the max of the last slice of the variable.


Thanks in advance!
--

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to