我需要在R中打印一个圆圈的迭代数:

print(paste("iteration",i,"/",ntot))
但我想在每次迭代时都删除/覆盖此行(每次迭代都很长...)。我该怎么做?

最佳答案

您可以尝试progress bar

ntot <- 100

pb <- txtProgressBar(min = 1, max = ntot, style = 3)
for(i in 1:ntot) {
  Sys.sleep(0.1)
  setTxtProgressBar(pb, i)
}
close(pb)

关于r - 删除/覆盖R中的print()消息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29631169/

10-12 16:37