I am trying to write a function to clear the global environment in R since I am too lazy to type rm(list=ls(all=T))
every time.
I tried
purge = function(){
rm(list=ls(all=T), envir = globalenv())
}
and
purge = function(){
rm(list=ls(all=T), pos = 1)
}
but they don't seem to be doing anything. There is a similar question that is targeted to a single object here but all I want to do is to clear everything in one go every single time. (I realize this function will also be gone after that but that is not an issue)