【问题标题】:Equivalent of Matlab "clearvars -except" in R [duplicate]R中的Matlab“clearvars -except”的等价物[重复]
【发布时间】:2017-04-30 19:48:49
【问题描述】:

我想删除一些变量,而不是像 remove()rm 那样全部删除。
在 Matlab 中我会写:
clearvars -except Environnement Species *_species Latitude Longitude

【问题讨论】:

  • 所以你想删除除指定变量之外的所有变量?
  • @JanSila 完全正确!你有什么想法吗?

标签: r matlab variables


【解决方案1】:

这是我能做的最好的。这将创建 a,b,c 并删除 Global Env 除了 b 之外的所有内容。

a<-1
b<-2
c<-1:5
rm(list = ls()[!ls() %in% c("b")])

【讨论】:

  • rm(list = setdiff(ls(), "b"))
  • yh,打败我的,在副本中看到了 :) 谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-01-17
  • 1970-01-01
  • 2011-01-07
  • 1970-01-01
  • 2021-03-13
  • 2011-09-12
  • 2021-11-02
相关资源
最近更新 更多