#' Replicate element and output a list
#'
#' @param x element to be repeated.
#' @param times the number of times to repeat \code{x}.
#'
#' @examples
#'
#' rep_list(1:10, 5)
#' rep_list("hello world!", 3)
#' rep_list(list(list(1:5, NA), "a"), 3)
#'
#' @export
rep_list <- function(x, times) {
if (length(times) > 1L) {
times <- times[1L]
warning("times has length > 1 and only the first element will be used")
}
if (times < 1L)
stop("times needs to be > 0")
lapply(1:times, function(i) x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.