I have the following simple for-loop, which makes R crash every time. The
length of the vectors is about 1200 rows, 1 column.

n = max(length(GSPC),length(FTSE))

for(i in 1:1000)
{
        if (row.names(GSPC)[i]==row.names(FTSE)[i]){
        } else {
                if (row.names(GSPC)[i]>row.names(FTSE)[i]){     
                GSPC<-rbind(GSPC[1:(i-1),],GSPC[(i-1):length(GSPC),])
                row.names(GSPC)[i]=row.names(FTSE)[i]
                } else {
                FTSE<-rbind(FTSE[1:(i-1),],FTSE[(i-1):length(FTSE),])
                row.names(FTSE)[i]=row.names(GSPC)[i]
                }
        }

}

I have no idea why it crashes, it should be a very simple task of running
through the 1200 entries. The if loop is called only about 10 times during
the entire loop.
What could be the problem?
-- 
View this message in context: 
http://n4.nabble.com/Simple-for-loop-runs-out-of-memory-tp1595698p1595698.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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