[R] How to abort function execution after x-seconds

Bert Gunter gunter.berton at gene.com
Sat Aug 20 23:16:19 CEST 2011


?proc.time

e.g. something like

time0 <- proc.time()[2]
state <- "not converged"
while(proc.time()[2] < time0[2] + 600 ) ## 10 minutes
{
##... Do your thing...
if(get an answer) {state <- "converged"; break}
}

Refinement required, but you get the idea.

Cheers,
Bert

On Sat, Aug 20, 2011 at 1:52 PM, Immanuel <mane.desk at googlemail.com> wrote:
> Hello all,
>
> I'm running a  parameter grid optimization ( ksvm, kernlab package) and the
> optimizer
> seems not to converge for certain parameters and stays in a infinity loop.
> Would it be possible to abort the execution after x-seconds and continue
> with the next parameter set? Which R function do need to use to accomplish
> this?
>
> I had a look at, try() etc. but they didn't seem so fit my needs.
> I would appreciate any suggestions..
>
> best regards
>
> ______________________________________________
> 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.
>



-- 
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics



More information about the R-help mailing list