[R] Extensively slowing for(i in 1:400) statement

Kallunki, Tuomas Tuomas.Kallunki at sofi.fi
Mon Jan 13 09:20:03 CET 2003


Hello!

Here is what I have tried to do:

1. I have 400 time series
2. pull one serie at a time from ODBC
3. calculate some descriptives and regressions (about 50 statistic per
serie)
4. store the results in the data frame

The problem:

The time consumed in each loop seems to grow linearly. I used the date()
function for timing each loop and time spent in loop seems to grow at the
speed of 0.6 * i (seconds), which implies that the last loop takes 245
seconds (first loop: 5 seconds). For the first 40 loop the ODBC down load
took 0-1 seconds, so I don't belive that ODBC connection is the problem. I
am running it in a computer with AMD 800Mhz/512 000 KB which should be
enough capacity. For example simple for(i in 1:100 000) statement runs very
smoothly? I will probably have to do several runs and I don't have the time
to wait half a day per run.

Can anyone tell what is the problem? 
Is it hardware related? 
Can the for() statement too long?
Do I have use rm() statement after each object becomes useless?
...?

Thanks,

Tuomas Kallunki




More information about the R-help mailing list