I have a function that potentially can take quite a long time.
I was wondering if there is a cleaner way to stop the function other than something like this:
repeat{
time1 <- Sys.time()
myfunction(x,y,z,...)
time2 <- Sys.time()
if(time2 - time1 > my.time.limit) {
break
}
}
There is an
evalWithTimeoutfunction in the R.utils package. You can use it like this:Run
example(evalWithTimeout)to see other ways to use it.