在R中显示状态消息 [英] showing a status message in R

查看:84
本文介绍了在R中显示状态消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个向用户显示状态消息的函数,该消息显示时间,完成百分比和进程的当前状态.我可以处理消息,但除了打印到控制台并使消息向上滚动外,我还想做其他事情,一个消息又一个消息.我真的很想更改消息,而不必像message()那样滚动并且没有任何图形. R有可能吗?

I'd like to write a function that presents to the user a status message that shows something like the time, the percent complete, and the current status of a process. I can handle assembling the message, but I'd like to do something other than just print to the console and have it scroll up, one message after the other. I'd really like the message to change without scrolling like message() and without any graphics. Is this possible with R?

推荐答案

这样的事情怎么样?

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()
}

这篇关于在R中显示状态消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆