[R] skip lapply item for conditions(RAM, execution time)
Joachim Harloff
joachim.harloff at joachimharloff.de
Thu Feb 18 17:06:24 CET 2010
Thank you,
but:
- How do I create a condition object watching for memory overflow? Or, alternatively, excess time?
- How do I tell R to end the current lapply item, clean up memory and proceed to the next item? (I know I can write a wrapper function including gc() and direct lapply to that wrapper function. But what do I do to stop ONLY the original function, not the whole R process?)
Joachim
> ?tryCatch
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On
> Behalf Of Joachim Harloff
> Sent: Wednesday, February 17, 2010 7:00 AM
> To: r-help at r-project.org
> Subject: [R] skip lapply item for conditions(RAM, execution time)
>
> Hi,
>
> I use lapply with a function from a package, and every 20th to 50th
> function
> execution (out of 500 to 10 000 times) fails for some unknown reason.
> RAM
> consumption ever increases (out of limit) and execution time is endless.
> I
> am not going to debug the package. (I rather feel like an end-user.)
>
> If it was Java, I'd wrap the function in a try...catch statement like
> about
>
> try{
> for(i=1;i<=10000;i++){
> dofunction(i);
> }
> }
> catch(outofmemoryexception e){
> kill(dofunctioninstance);
> gc();
> next;
> }
>
>
> I did not find out how to construct this in R. Is anyone so kind to
> point me
> to a documentation more exhaustive than help(conditions)? Or otherwise
> provide a snippet of R code?
>
> Regards, Joachim
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list