Re: [R] Speeding nested loops up

2011-08-17 Thread Daniel Malter
General suggestions: avoid cbind() and avoid accessing data frames. Convert data frames to matrices before accessing them. Also, why do you print? You don't really want to print(t) for every iteration of the loop, do you? Also avoid defining elements within the loop that need to be defined only

[R] Speeding nested loops up

2011-08-17 Thread mark_horo
Hi I'm trying to speed my loop up. Any Suggestions?? At the moment it takes a few days to run. THE CODE --- for(i in 1:11) { for (j in 3:12) { for (k in

Re: [R] Speeding nested loops up

2011-08-17 Thread David Winsemius
On Aug 17, 2011, at 8:14 PM, mark_horo wrote: Hi I'm trying to speed my loop up. Any Suggestions?? At the moment it takes a few days to run. THE CODE We are not surprised. Rainfall_dataset - read.table(1km_grid_nzmg.csv, header=TRUE, sep=,, na.strings=NA, dec=.,

Re: [R] Speeding nested loops up

2011-08-17 Thread Jim Holtman
anytime my code starts to take more than a couple of minutes to run what might look like a simple set of commands, I use Rprof to see where the time goes. Run this on your script and you might get some insight into the problem area. If it ran for an hour, I would defintely take a deep dive

Re: [R] Speeding nested loops up

2011-08-17 Thread stephen sefick
foreach and allied packages have helped me speed up some code significantly. I have four cores in my machine and this allows me to get away with this... HTH Stephen On Wed, Aug 17, 2011 at 9:59 PM, Jim Holtman jholt...@gmail.com wrote: anytime my code starts to take more than a couple of