R/make_copy.R

Defines functions make_copy

Documented in make_copy

#' Duplicate an object in the global environment
#'
#' Duplicate an oject in the global environment, so that one version can be modified without losing the previous version. Useful for testing modifications to objects generated by time-consuming code.
#' @param var_name character string, the name of the object to be copied.
#' @param append character string, the text to be appended to the object's name when making the copy. Defaults to ".old".
#' @export
#' @usage \code{make_copy(var_name, append=".old")}
make_copy <- function(var_name, append=".old") {
  assign(paste0(var_name, append), get(var_name), envir = .GlobalEnv)
}
mjdufort/miscHelpers documentation built on Sept. 24, 2018, 7:09 p.m.