Overwrite current output in the R console

后端 未结 5 901
醉梦人生
醉梦人生 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:23

    In case you want to use the function message to print something, you can set its parameter appendLF to FALSE to avoid it printing a new line and then the use the carriage return ('\r') character to return to the start of the line, for example:

    for (i in 1:5) {
      message('\r', i, appendLF = FALSE)
    }
    

提交回复
热议问题