progress is not updating the progress bar on a single line
Closed this issue · 5 comments
It seems like it is not possible. What does this print for you?
{
cat("foo")
cat("\rbar\n")
}
Just executing that block in a cell, I got
bar
Hi there,
I've got the same problem, with the following code...
pb <- progress_bar$new(total = length(filelist), format = "\nCorrecting divergent files [:bar] :percent eta: :eta")
for(i in 1:length(filelist)){
pb$tick()
aux <- read.table(filelist[i])
Sys.sleep(1/100)
}
... and the output is a bit strange, multiline:
Correcting divergent files [>---------------------------------] 3% eta: 8s
Correcting divergent files [>---------------------------------] 4% eta: 6s
Correcting divergent files [=>--------------------------------] 6% eta: 9s
Correcting divergent files [=>--------------------------------] 7% eta: 9s
Correcting divergent files [==>-------------------------------] 8% eta: 10s
Correcting divergent files [==>-------------------------------] 10% eta: 12s
Correcting divergent files [===>------------------------------] 11% eta: 13s
Correcting divergent files [===>------------------------------] 13% eta: 15s
Correcting divergent files [====>-----------------------------] 14% eta: 14s
Correcting divergent files [====>-----------------------------] 15% eta: 17s
Correcting divergent files [=====>----------------------------] 17% eta: 18s
Correcting divergent files [=====>----------------------------] 18% eta: 22s
Correcting divergent files [======>---------------------------] 20% eta: 21s
Correcting divergent files [======>---------------------------] 21% eta: 20s
Correcting divergent files [=======>--------------------------] 23% eta: 19s
Correcting divergent files [=======>--------------------------] 24% eta: 18s
Correcting divergent files [========>-------------------------] 25% eta: 17s
Correcting divergent files [========>-------------------------] 27% eta: 16s
Correcting divergent files [=========>------------------------] 28% eta: 16s
Any idea what I'm doing wrong, please? Thanks in advance!
Hey @jgarces02 I believe your issue is caused by the newline "\n"
in your format argument.
The newline is included every time the progress bar is updated and as such it appears on a new line every time.
If you do want a newline before the progress bar is printed (for instance if you are printing other things to the console beforehand) I would suggest including a newline before you start your progress bar. For instance:
pb <- progress_bar$new(total = length(filelist), format = "Correcting divergent files [:bar] :percent eta: :eta")
cat("\n")
for(i in 1:length(filelist)){
pb$tick()
aux <- read.table(filelist[i])
Sys.sleep(1/100)
}
I hope this solves your issue (and potentially that of @Moosquibe as well)
Perfect, I catch it, I'll try as soon as possible. Thanks a lot for your help!