R/clear.R

#' Clear Everything From R Session
#'
#' Clears all objects, variables, and figures from R.  Optional argument to reset R.
#' @param resetR Logical; Optional argument to reset entire R session. Helps to clear memory. Defaults to FALSE.
#' @export
#' @return Head of x.
#' @examples
#' clear()

clear <- function(resetR = FALSE){
  cat("\014")
  rm(list  = ls(envir = as.environment('.GlobalEnv')),
     envir = as.environment('.GlobalEnv'))
  if (dev.cur() != 1)  dev.off()
  gc()
  if (resetR) .rs.restartR()
}
ssaxe-usgs/saxey documentation built on May 25, 2019, 5:02 a.m.