Jos*_*ich 26
这样的事怎么样?
for(i in 1:10) {
Sys.sleep(0.2)
# Dirk says using cat() like this is naughty ;-)
#cat(i,"\r")
# So you can use message() like this, thanks to Sharpie's
# comment to use appendLF=FALSE.
message(i,"\r",appendLF=FALSE)
flush.console()
}
Run Code Online (Sandbox Code Playgroud)
Sha*_*pie 17
该utils软件包包含txtProgressBar用于更新它的函数和函数,可用于显示进程的完成百分比.
见up1,up2和up3那些对通话过程中创建的功能txtProgressBar为更新的方式无需滚动控制台处理的例子.
Rom*_*rik 15
这是一些金光闪闪的金光闪闪.来自?tcltk::tkProgressBar.
pb <- tkProgressBar("test progress bar", "Some information in %",
0, 100, 50)
Sys.sleep(0.5)
u <- c(0, sort(runif(20, 0 ,100)), 100)
for(i in u) {
Sys.sleep(0.1)
info <- sprintf("%d%% done", round(i))
setTkProgressBar(pb, i, sprintf("test (%s)", info), info)
}
Sys.sleep(5)
close(pb)
Run Code Online (Sandbox Code Playgroud)

可能有更优雅的方法来做到这一点,但这可以做到:
test.message <- function() {
for (i in 1:9){
cat(i)
Sys.sleep(1)
cat("\b")
}
}
Run Code Online (Sandbox Code Playgroud)
如果您自动生成消息,则需要计算要输出的\ b个字符数以备份正确的数量,但这非常简单.
| 归档时间: |
|
| 查看次数: |
15628 次 |
| 最近记录: |