EVOLUTION-MANAGER
Edit File: later.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Executes a function later</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for later {later}"><tr><td>later {later}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Executes a function later</h2> <h3>Description</h3> <p>Schedule an R function or formula to run after a specified period of time. Similar to JavaScript's <code>setTimeout</code> function. Like JavaScript, R is single-threaded so there's no guarantee that the operation will run exactly at the requested time, only that at least that much time will elapse. </p> <h3>Usage</h3> <pre> later(func, delay = 0, loop = current_loop()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>func</code></td> <td> <p>A function or formula (see <code><a href="../../rlang/html/as_function.html">rlang::as_function()</a></code>).</p> </td></tr> <tr valign="top"><td><code>delay</code></td> <td> <p>Number of seconds in the future to delay execution. There is no guarantee that the function will be executed at the desired time, but it should not execute earlier.</p> </td></tr> <tr valign="top"><td><code>loop</code></td> <td> <p>A handle to an event loop. Defaults to the currently-active loop.</p> </td></tr> </table> <h3>Details</h3> <p>The mechanism used by this package is inspired by Simon Urbanek's <a href="https://github.com/s-u/background">background</a> package and similar code in Rhttpd. </p> <h3>Value</h3> <p>A function, which, if invoked, will cancel the callback. The function will return <code>TRUE</code> if the callback was successfully cancelled and <code>FALSE</code> if not (this occurs if the callback has executed or has been cancelled already). </p> <h3>Note</h3> <p>To avoid bugs due to reentrancy, by default, scheduled operations only run when there is no other R code present on the execution stack; i.e., when R is sitting at the top-level prompt. You can force past-due operations to run at a time of your choosing by calling <code><a href="run_now.html">run_now()</a></code>. </p> <p>Error handling is not particularly well-defined and may change in the future. options(error=browser) should work and errors in <code>func</code> should generally not crash the R process, but not much else can be said about it at this point. If you must have specific behavior occur in the face of errors, put error handling logic inside of <code>func</code>. </p> <h3>Examples</h3> <pre> # Example of formula style later(~cat("Hello from the past\n"), 3) # Example of function style later(function() { print(summary(cars)) }, 2) </pre> <hr /><div style="text-align: center;">[Package <em>later</em> version 1.1.0.1 <a href="00Index.html">Index</a>]</div> </body></html>