Overwrite current output in the R console

后端 未结 5 900
醉梦人生
醉梦人生 2021-01-01 18:43

I have been playing around with the R function txtProgressBar(). How can I hijack the function\'s ability to overwrite the current output in the console?

i.e. the p

5条回答
  •  悲哀的现实
    2021-01-01 19:34

    I do not think overwriting is possible on the console. There is no backspace escape sequence. The progress bar can be drawn because the cat function will not emit a cr unless told to do so.

    Edit: I was wrong. The backspace character is recognized:

    for (i in 1:1000) {
         cat(as.character(Sys.time())) 
         flush.console() 
         for(i in 1:19) {cat("\8")} }
    

提交回复
热议问题