Run Code in the Background
Run an R function in the background, possibly after a delay. The current version uses the Tcl event loop and was ported from the 'tcltk2' package.
source("https://install-github.me/gaborcsardi/after")
library(after)
Run a function five seconds later:
after(5000, function() cat("Here I am!\n"))
Call a function in a package. It is good practice to create an anonymous function for this:
after(5000, function() utils::alarm())
Run a function every three seconds:
id <- after(3000, function() cat("Still here!\n"), redo = Inf)
Sys.sleep(10)
Still here!
Still here!
Still here!
Cancel it:
after$cancel(id)
LGPL-3 © Gábor Csárdi
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.