timeout: Stop the execution of an expression if the elapsed time...

View source: R/timeout.R

timeoutR Documentation

Stop the execution of an expression if the elapsed time exceed a limit

Description

Stop the execution of an expression if the elapsed time exceed a limit

Usage

timeout(expr, timeout)

Arguments

expr

R expression such as sum(1:5) and muli-line R code inside .

timeout

numeric, time limit in second

Value

return of expr

Examples

timeout(
  {
    for (i in 1:10) {
      print(i)
    }
  },
  timeout = 1
)


GL-Li/mytoolbox documentation built on May 16, 2024, 4:29 p.m.