I tried this command
remove(list = ls())
I expect to clear all R environment (Objects, packages)
The console can be cleared using the shortcut key “ctrl + L“.
Remove Objects from Memory in R Programming – rm() Function rm() function in R Language is used to delete objects from the memory. It can be used with ls() function to delete all objects. remove() function is also similar to rm() function.
You can restart R by clicking on Session -> Restart R (top menu).
Ctrl+L — Clear the Console. Esc — Interrupt R.
The simplest and, more importantly, the only reliable way of doing this is to restart R. That takes care of everything.
Just make sure you’re not accidentally saving the current R image when quitting R.
In RStudio, you need to set the option “Save workspace to .RData file on exit” to “Never”, and disable restoring upon restart — this is strongly recommended!
After that, make sure that any previously existing .RData
files in your project’s folder are deleted (heads up: .RData
is an invisible file so you won’t normally see it in a file browser; you can delete it via the command line).
To restart R from within RStudio, you can use “Session” › “Restart R” or Cmd+Shift+F10.
The answer was already out there :-) https://stackoverflow.com/a/7506112/7902133
According to this answer, the following code should work
lapply(paste("package:", names(sessionInfo()$otherPkgs), sep=""),
detach,
character.only = TRUE,
unload = TRUE)
You may also want to check the first answer for a full description.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With