简体   繁体   English

R:如何摆脱存储在全局环境中的默认数据和值

[英]R: How to get rid of default data and values stored in global environment

Every time I open my laptop R, the same data and values (data tables and variables I used in the past) keep on appearing, and it's annoying to rm() them every time I open a new file to work on something else.每次我打开笔记本 R 时,相同的数据和值(我过去使用的数据表和变量)不断出现,每次打开新文件处理其他事情时, rm()它们很烦人。 My question is: 1) Is there a way to reset or set default data and variables in global environment?我的问题是:1)有没有办法在全局环境中重置或设置默认数据和变量? For example, if I'm working on file1 , I want to use data table data1 , data2 , and data3 and variable v1 , v2 , and v3 .例如,如果我正在处理file1 ,我想使用数据表data1data2data3以及变量v1v2v3 It'd be nice if I can store these set of data and variables for file1 specifically and simply call them instead of loading the data and running the codes every time I open the file.如果我可以专门为file1存储这些数据和变量集,并且只需调用它们而不是每次打开文件时加载数据和运行代码,那就太好了。

Thank you!谢谢!

In RStudio, press the button with the broom icon to remove all objects from the environment.在 RStudio 中,按下带有扫帚图标的按钮可从环境中移除所有对象。 Include hidden objects.包括隐藏的对象。 Then, quit RStudio and make sure to save the workspace image to ~/.Rdata.然后,退出 RStudio 并确保将工作区图像保存到 ~/.Rdata。 This should fix your problem.这应该可以解决您的问题。 When you open RStudio again, the Global Environment should be empty.再次打开 RStudio 时,全局环境应该是空的。

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

相关问题 如何在R中导入数据时摆脱NA值? - How can I get rid of NA values on data import in R? 如何从调用环境而不是封闭环境中获取 R 函数的默认值 - How to get an R function's default values from the calling environment, not the enclosing environment 如何将全局环境中的列表数据放入列表中 - How to get a list data that are in global environment into a list 如果对象存在于全局中,则R从函数中获取来自全局环境的对象,否则使用不同的默认值 - R get object from global environment from function if object exists in global but use different default if not R Studio-全局环境中的数据在启动时自动加载-如何删除 - R Studio - data in Global Environment automatically loads on startup - how to remove 如何在 Global R 环境中加载动态数据框? - How load a dynamic data frame in Global R environment? 在R中将值从函数绑定到全局环境 - Binding values from function to global environment in R Rscript - 摆脱“警告:忽略R_HOME的环境价值” - Rscript - get rid of “WARNING: ignoring environment value of R_HOME” R - 水管工,如何将值传递给全局环境? - R - plumber, how to pass a value to the global environment? 如何遍历全局环境中的对象 - R. - How to loop through objects in the global environment - R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM