Saturday, January 7, 2023

Cleanup Commands in R

 By running the following commands, the history, console, and graphs will be cleaned out from the R windows. 

#------- clear working environment

rm(list = ls())

#---- clear history in R

clearhistory <- function() {

  write("", file=".blank")

  loadhistory(".blank")

  unlink(".blank")

}

clearhistory()

#----------clean all plots/graphs in R

dev.off(dev.list()["RStudioGD"])

#--------- clear console in R

shell("cls")

# close R 

quit()

No comments:

Post a Comment