如何在R中停止for循环并保留数据

时间:2016-04-19 21:09:48

标签: r for-loop

我的代码在for循环中运行。代码需要一段时间才能运行,还剩下几天,但我迫切需要有任何结果。有没有办法打破代码/ for循环,但保留到目前为止生成的任何数据。

1 个答案:

答案 0 :(得分:0)

是。您可以按"转义",检查结果,然后重新启动循环。

for(iii in 1:100000000) force(iii)
# now press ESC
iii
# in my case 1121673
# use this value to restart the loop later:
for(iii in 1121674:100000000) force(iii)