Learn how to do some basic debugging.  If you are running out of memory
after 10 times, then you must be creating a large object and using up
memory.  Put:

cat(i, memory.size(), '\n')

In your loop to see how memory is being used.  You might also look at the
size of the objects you are creating.

You also did not give the specific message when the system "crashed", but
you should now be able to discover for yourself what is happening.

On Tue, Mar 16, 2010 at 5:51 PM, Astrix <ast_rix85@hotmail.com> wrote:

>
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

	[[alternative HTML version deleted]]

