'How to provide a tidy R console update message in RStudio?
This code lets me leave a nice message (on Windows) in the R console, without fill up the screen:
imax <- 2000
for (i in seq_len(imax)) {
mess <- sprintf("slightly different length message: %i", i)
message(paste(rep("\b", nchar(mess)), collapse = ""), appendLF = FALSE)
message(mess, appendLF = i == imax)
flush.console()
}
In RStudio the backspace character doesn't work and I get horrible appended messages everywhere.
How can I do this nicely in both Rgui and RStudio?
What about cross-platform?
Solution 1:[1]
You can use cat using \r, that is
cat("\r", "slightly different length message:", i)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vassilis Chasiotis |
