#' 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()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.