#' Restores a backed up object
#'
#' Function takes the name of the object and checks if there is a backup of it;
#' if there is, restores it.
#'
#' @param object the object to restore (use the original name, not the one with
#' "_bak").
#' @keywords backup, restore
#' @export
#' @examples
#' (test <- 1:10)
#' backup(test)
#' (test <- 11:20)
#' (restore(test))
restore <-
function(object) {
bak_name <-
paste0(deparse(substitute(object)),
"_bak")
if(exists(bak_name)) {
assign(deparse(substitute(object)),
get(bak_name),
pos = parent.frame())
} else {
warning(paste0("No backup found for '",
deparse(substitute(object)),
"'"))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.