Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/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_Vector - Fatal编程技术网

R 遍历存储在向量中的值

R 遍历存储在向量中的值,r,loops,vector,R,Loops,Vector,在下面的代码中,我试图找出唯一的区域名称,然后进行迭代,但是当我运行它时,它只打印出一行 这是我的代码: ZonelistName<-unique(temp[c("zone")]) #this is where the LSD for the zone will be for (p in c(ZonelistName)) { print(p) } 抱歉,我无法复制它,因为我不知道该对象是什么我想您可能需要取消列表而不是c 或 给 [1

在下面的代码中,我试图找出唯一的区域名称,然后进行迭代,但是当我运行它时,它只打印出一行

这是我的代码:

 ZonelistName<-unique(temp[c("zone")])
  
  #this is where the LSD for the zone will be
  
  for (p in c(ZonelistName)) {
    print(p)
  }
抱歉,我无法复制它,因为我不知道该对象是什么

我想您可能需要取消列表而不是c

[1] 3
[1] 2
[1] 5
[1] 1

你看过ZonelistName的内容了吗?比如说headZonelistName?如果您包含一个简单的示例输入和所需输出,可以用来测试和验证可能的解决方案,那么就更容易为您提供帮助。什么是temp?给我们dputheadZonelistName的输出。我想你需要的是ZonelistName
for (p in unlist(ZonelistName)) {
  print(p)
}
for (p in ZonelistName$zone) {
  print(p)
}
[1] 3
[1] 2
[1] 5
[1] 1