[R] Time out for a R Function
Santosh Srinivas
santosh.srinivas at gmail.com
Wed Dec 8 16:14:32 CET 2010
Thank you.
I tried this but not sure if I have implemented this correctly ... basically
if function1 hangs .. I need the timeout to be triggered and then the
process moves to the next function call.
I have this:
function1 <- function(x){
setTimeLimit(elapsed = 5*60, transient = FALSE)
step 1
step 2
step 3
}
#Code to execute about function repeatedly. It moves to a new input variable
when I call it back through a parameter
repeat{
function1(x)
}
-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
Sent: 07 December 2010 13:23
To: Santosh Srinivas
Cc: r-help at r-project.org
Subject: Re: [R] Time out for a R Function
On Tue, 7 Dec 2010, Santosh Srinivas wrote:
> Hello Group,
>
> I have an R-function that works fine for most part but sometime runs into
a
> long loop! (I'm lazy and short on time to debug right now so want to do
> something easy)
> For my purpose, it is ok to make few errors .... is there a way I can put
a
> timeout on a function and the r-process needes to move on to the next
step?
See the help on setTimeLimit(transient = FALSE) . Unlike other
suggestions, that does not need you to change the code to check the
time.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list