[R] skip lapply item for conditions(RAM, execution time)

Joachim Harloff joachim.harloff at joachimharloff.de
Wed Feb 17 15:59:40 CET 2010


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



More information about the R-help mailing list