Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用循环删除环境元素_R_Loops - Fatal编程技术网

R 使用循环删除环境元素

R 使用循环删除环境元素,r,loops,R,Loops,我在环境中有16个元素,称为Factor1到Factor16。我想自动删除它们。我写的,我不明白为什么不起作用 for(i in 1:16) { rm(paste0('Factor',i)) } 对不起,这个基本问题,我是初学者 for(i in 1:16) { rm(list=paste0('Factor',i)) } 虽然rm(list=paste0('Factor',1:16))或rm(list=ls(pattern=“Factor”))更合适 再次感谢。不知

我在环境中有16个元素,称为Factor1到Factor16。我想自动删除它们。我写的,我不明白为什么不起作用

 for(i in 1:16) {
    rm(paste0('Factor',i))
  }
对不起,这个基本问题,我是初学者

for(i in 1:16) {
    rm(list=paste0('Factor',i))
  }

虽然
rm(list=paste0('Factor',1:16))
rm(list=ls(pattern=“Factor”))
更合适

再次感谢。不知道列表函数。这样就不需要循环了。虽然我的情况是0。当然,我用你的答案发现了后者。编辑;)