Home > database >  Clearing workspace and sourcing script in one go in rstudio
Clearing workspace and sourcing script in one go in rstudio

Time:12-17

Is there a way (shortcut or button or so) that allows me to clear the workspace and then source the current .r script?

CodePudding user response:

You can prior to sourcing your .R file do a few cleanups

Clean your workspace environment rm(list = ls())

Clear the plots tab if(!is.null(dev.list())) dev.off()

Clear the console cat("\014") (same as the shortcut Ctrl L)

CodePudding user response:

So, I found a non-ideal but will-do solution myself. Using the RStudio shortcut manager, you can define a shortcut to clean the workspace. I bound this to CTRL SHIFT X, such that it is close to the shortcut for sourcing the script, CTRL SHIFT S. However, clearing the workspace has a warning pop-up, so eventually, the routine becomes CTRL SHIFT X - ENTER - CTRL SHIFT S.

  • Related