正常情况下对X的循环不会出错
> x<-c(11,22,33,44,55,66,77)
> for(i in 1:length(x)){print(x[i])}
[1] 11
[1] 22
[1] 33
[1] 44
[1] 55
[1] 66
[1] 77```
###当y是空向量循环会出错
y<-c()
for(i in 1:length(y)){print(y[i])}
NULL
NULL```
使用seq函数则不会出错
for(i in seq(y)){print(y[i])}
seq对正常情况也能处理
> for(i in seq(x)){print(x[i])}#效果和使用length相同
[1] 11
[1] 22
[1] 33
[1] 44
[1] 55
[1] 66
[1] 77```