From maechler at stat.math.ethz.ch  Wed Dec  7 11:58:02 2016
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed, 7 Dec 2016 11:58:02 +0100
Subject: [Rd] Strange behavior when using progress bar (Fwd: Re: [R] The
 code itself disappears after starting to execute the for loop)
In-Reply-To: <ec37a17e-b2ee-b1df-2490-6006f49b886c@jrc.ec.europa.eu>
References: <54b8d998-9299-4034-be0a-9c9ad7169974@jrc.ec.europa.eu>
	<fdd2811e-60af-e322-4e33-0c1ad5eab0ee@jrc.ec.europa.eu>
	<ec37a17e-b2ee-b1df-2490-6006f49b886c@jrc.ec.europa.eu>
Message-ID: <22599.60218.182964.817869@stat.math.ethz.ch>

>>>>> Jon Skoien <jon.skoien at jrc.ec.europa.eu>
>>>>>     on Wed, 7 Dec 2016 11:04:04 +0100 writes:

    > I would like to ask once more if this is reproducible also for others? 
    > If yes, should I submit it as a bug-report?

    > Best,
    > Jon

Please  Windows users .. this is possibly only for you!

Note that I do *not* see problems on Linux (in ESS; did not try RStudio).

Please also indicate in which form you are running R.
Here it does depend if this is inside RStudio, ESS, the "Windows
GUI", the "Windows terminal", ...

Martin Maechler,
ETH Zurich


    > On 11/28/2016 11:26 AM, Jon Skoien wrote:
    >> I first answered to the email below in r-help, but as I did not see 
    >> any response, and it looks like a bug/unwanted behavior, I am also 
    >> posting here. I have observed this in RGui, whereas it seems not to 
    >> happen in RStudio.
    >> 
    >> Similar to OP, I sometimes have a problem with functions using the 
    >> progress bar. Frequently, the console is cleared after x iterations 
    >> when the progress bar is called in a function which is wrapped in a 
    >> loop. In the example below, this happened for me every ~44th 
    >> iteration. Interestingly, it seems that reduction of the sleep times 
    >> in this function increases the number of iterations before clearing. 
    >> In my real application, where the progress bar is used in a much 
    >> slower function, the console is cleared every 2-3 iteration, which 
    >> means that I cannot scroll back to check the output.

 testit <- function(x = sort(runif(20)), ...) {
   pb <- txtProgressBar(...)
   for(i in c(0, x, 1)) {Sys.sleep(0.2); setTxtProgressBar(pb, i)}
   Sys.sleep(1)
   close(pb)
 }
 
 it <- 0
 while (TRUE) {testit(style = 3); it <- it + 1; print(paste("done", it))}

    >> Is this only a problem for a few, or is it reproducible? Any hints to
    >> what the problem could be, or if it can be fixed? I have seen this in 
    >> some versions of R, and could also reproduce in 3.3.2.

"some versions of R" ... all on Windows ?

    >> 
    >> Best wishes,
    >> Jon
    >> 
    >> R version 3.3.2 (2016-10-31)
    >> Platform: x86_64-w64-mingw32/x64 (64-bit)
    >> Running under: Windows 8.1 x64 (build 9600)
    >> 
    >> locale:
    >> [1] LC_COLLATE=English_United States.1252
    >> [2] LC_CTYPE=English_United States.1252
    >> [3] LC_MONETARY=English_United States.1252
    >> [4] LC_NUMERIC=C
    >> [5] LC_TIME=English_United States.1252
    >> 
    >> attached base packages:
    >> [1] stats     graphics  grDevices utils     datasets  methods base

[.....................]

    > Jon Olav Sk?ien
    > Joint Research Centre - European Commission
    > Institute for Space, Security & Migration
    > Disaster Risk Management Unit

    > Via E. Fermi 2749, TP 122,  I-21027 Ispra (VA), ITALY

    > jon.skoien at jrc.ec.europa.eu
    > Tel:  +39 0332 789205



[Rd] Strange behavior when using progress bar (Fwd: Re: [R] The code itself disappears after starting to execute the for loop)
Martin Maechler