powered by
This function interrupts an evaluation after a certain number of seconds. Note the limitations documented in setTimeLimit.
setTimeLimit
timed(expression, seconds = Inf, on_time_out = "silent")
The value of expression or, if the evaluation time exceeded, whatever is specified for on_time_out.
expression
on_time_out
[expression] An R expression to be evaluated.
[numeric(1)] The number of seconds.
numeric(1)
[character(1)] Defines what action to take if the evaluation time exceeded, either:
character(1)
"error" to throw an error exception
"error"
"warning" to return NULL along with a warning
"warning"
NULL
"silent" (the default) to just return NULL
"silent"
Other function helpers: do.call_timed(), function_arguments(), function_body(), function_defaults(), quiet(), try_silent(), variable_name()
do.call_timed()
function_arguments()
function_body()
function_defaults()
quiet()
try_silent()
variable_name()
foo <- function(x) { for (i in 1:10) Sys.sleep(x / 10) return(x) } timed(foo(0.5), 1) timed(foo(1.5), 1)
Run the code above in your browser using DataLab