Clear/reset an RStudio session
clear(detach = TRUE)
detach | logical. If |
---|
The clear()
function:
Clears the console window
Deletes objects from the global environment
Deletes plots and plot history from the Plots window
Unloads all but base packages (unless detach=FALSE
)
Releases memory (garbage collection)
R scripts and Rmarkdown files are left untouched. No objects saved to disk are affected.
This is a good way to start a fresh R session without having to quit and restart RStudio. Additionally, any script or Rmarkdown files remain open, the current working directory is unchanged, and you remain in any open project.
if (FALSE) { clear() }