#' Delay the execution of a function
#'
#' @param delay The delay in seconds
#' @param f The function to be called
#' @references This function is borrowed from Hadley Wickham, \emph{Advanced R}
#' (Chapman and Hall, 2014),
#' \href{http://adv-r.had.co.nz/Function-operators.html}{section 12.1}.
#' @return A delayed version of function \code{f}.
#' @examples
#' f <- delay_by(1, sqrt)
#' sapply(1:3, f)
#' @export
delay_by <- function(delay = 1, f) {
function(...) {
Sys.sleep(delay)
f(...)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.