[R] How to speed up the for loop by releasing memeory

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Sat Dec 15 17:00:48 CET 2012

Please read the posting guide. You need to provide reproducible code (please simplify, but make sure it illustrates your problem and runs) to communicate clearly what problem you are trying to solve.

Chances are good that you don't need any for loop at all, but without running code we can't tell.
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

Yong Wang <wangyong1 at gmail.com> wrote:

>Dear list;
>How can I speed up the run of following code (illustrative)
>for (i in 1:limit)
>if(matched data for the ith item found) {
>            if(i==1) {con<-RowOfMatchedData } else
>                                                        }
>each RowOfMatchedData contains 105 variables, when "i" runs over 10^7
>and the data container "con" get large enough, the codes get extremely
>slow, I know this is a working memory problem (2GB only), is there
>anyway to circumvent this problem without dicing and slicing the data.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list