#' Loads an R object based on name if a corresponding R data file is in the working directory
#' @param robj R object
#' @importFrom readr read_rds
#' @export
#'
load_robj <-
function(robj) {
robj_name <- deparse(substitute(robj))
fn <- paste0(robj_name, ".RData")
if (file.exists(fn)) {
x <- readr::read_rds(fn)
assign(robj_name, x, envir = globalenv())
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.