Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

showing a status message in 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?

like image 447
JD Long Avatar asked Jan 21 '11 03:01

JD Long


People also ask

How do I show messages in R?

To display ( or print) a text with R, use either the R-command cat() or print(). Note that in each case, the text is considered by R as a script, so it should be in quotes. Note there is subtle difference between the two commands so type on your prompt help(cat) and help(print) to see the difference.

How to stop error message in R?

The stop R function generates an error message and stops executing the current R code.


1 Answers

How about something like this?

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() } 
like image 120
Joshua Ulrich Avatar answered Sep 26 '22 08:09

Joshua Ulrich