[英]Removing variables loaded from an RData file in R
Suppose I saved two variables:假设我保存了两个变量:
x <- rnorm(5)
y <- letters[1:10]
save(x, y, file = "MySavedList.RData")
rm(x,y)
Later, I want to load this saved file ( MySavedList.RData
) and after using these variables I want to remove only the variables that are loaded from MySavedList.RData
.后来,我想加载这个保存的文件(
MySavedList.RData
),在使用这些变量后,我只想删除从MySavedList.RData
加载的变量。 All of the remaining variables in the environment should be intact.环境中的所有剩余变量都应该完好无损。 Something like this:
像这样的东西:
load(file = "MySavedList.RData")
...
rm("Variables loaded from MySavedList.RData")
I don't want to load these files into a new environment ( like this post ), or create a variable that holds the variable names when I first save the variables.我不想将这些文件加载到新环境中(如这篇文章),也不想在我第一次保存变量时创建一个保存变量名称的变量。
Would something like this work for you?这样的事情对你有用吗?
theloadedobjects <- load(file = "MySavedList.RData")
...
rm(list=c(theloadedobjects, "theloadedobjects"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.