R语言学习-repeat循环

repeat循环=while(true)循环

i = 0

repeat {
i <- i+1
if(i==4) {
next;
}
print(1:i);
if(i==10) {
break;
}
}

 

输出结果:

[1] 1
[1] 1 2
[1] 1 2 3
[1] 1 2 3 4 5
[1] 1 2 3 4 5 6
[1] 1 2 3 4 5 6 7
[1] 1 2 3 4 5 6 7 8
[1] 1 2 3 4 5 6 7 8 9
[1] 1 2 3 4 5 6 7 8 9 10

posted @ 2017-08-14 12:50  绪哥哥  阅读(844)  评论(0编辑  收藏  举报