R/rm_if_exists.R

Defines functions rm_if_exists

Documented in rm_if_exists

#' Removes R objects in the global environment if R object doesn't exist
#' @param r_object single R object that is removed if it is present in the environment
#' @export

rm_if_exists <-
        function(r_object) {
                if (exists(deparse(substitute(r_object)), envir = globalenv())) {
                        rm(list = deparse(substitute(r_object)), envir = globalenv())
                }
        }
patelm9/mirroR documentation built on Feb. 12, 2020, 2:41 p.m.