Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing all user-defined objects in R workspace

I'm working with Rserve via Ruby bindings. It's pretty trivial to establish a connection to Rserve, and I assume its a good idea to persist that connection globally to avoid the overhead of tearing it down and re-building it as needed (I'm not operating in a multi-threaded environment).

Since the objects defined will stick around, and potentially class with later operations, I want to clear them out. I've seen:

myvar = 1
rm(myvar)

However, I would rather re-initialize everything, to avoid having to manually keep track of whats defined. Is this possible? Is there a significant overhead associated with it if so?

like image 541
Allyl Isocyanate Avatar asked Aug 26 '13 20:08

Allyl Isocyanate


2 Answers

it is a bit dangerous but: rm(list=ls()) really, don't do this.

like image 116
Seth Avatar answered Oct 26 '22 22:10

Seth


If you are working with a dataset let say named data_new, you can use the following comment to remove all information about data_new from your workspace:

rm(data = data_new)

like image 36
Amir Avatar answered Oct 26 '22 22:10

Amir