简体   繁体   English

清除R工作空间中的所有用户定义对象

[英]Clearing all user-defined objects in R workspace

I'm working with Rserve via Ruby bindings. 我正在通过Ruby绑定与Rserve合作。 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). 建立与Rserve的连接非常简单,我认为最好在全局范围内保持连接,以避免将其拆除并根据需要重新构建它的开销(我不是在多线程环境中运行) 。

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? 如果是这样,是否会产生很大的开销?

这有点危险但是: rm(list=ls())真的,不要这样做。

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: 如果您正在使用数据集,请说出名为data_new,您可以使用以下注释从工作区中删除有关data_new的所有信息:

rm(data = data_new) rm(data = data_new)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM