[Rd] Strange behavior when using progress bar (Fwd: Re: [R] The code itself disappears after starting to execute the for loop)
Jon Skoien
jon.skoien at jrc.ec.europa.eu
Wed Dec 7 11:04:04 CET 2016
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
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)
> }
>
> iter = 0
> while (TRUE) {testit(style = 3); iter = iter + 1; print(paste("done",
> iter))}
>
> 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.
>
> 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
>
>
>
>
> On 11/23/2016 5:22 PM, Maram SAlem wrote:
>> Thanks a lot Bert , will check out your suggestions.
>>
>> I've unchecked the buffer output option in GUI but still have the
>> same problem.
>>
>> Thanks for your time and concern.
>>
>> Maram Salem
>>
>> Sent from my iPhone
>>
>>> On Nov 23, 2016, at 5:55 PM, Bert Gunter <bgunter.4567 at gmail.com>
>>> wrote:
>>>
>>> In addition to Jim's comments, which you have not yet satisfactorily
>>> addressed (buffering in GUI??),
>>>
>>> 1. Show your code!
>>>
>>> 2. Show ouput of sessionInfo()
>>>
>>> 3. Upgrade to the latest R version maybe
>>>
>>> 4. Perhaps write to package maintainer (see ?maintainer) if nothing or
>>> no one helps.
>>>
>>> Cheers,
>>> Bert
>>>
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming along
>>> and sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>>
>>>> On Tue, Nov 22, 2016 at 10:05 AM, Maram SAlem
>>>> <marammagdysalem at gmail.com> wrote:
>>>> Thanks for helping Jim.
>>>>
>>>> I'm actually using the pbapply function together with the print
>>>> function within a loop. In earlier versions, the progress bar and
>>>> the output of the print function used to appear after each
>>>> iteration of the loop. But with the 3.3.1. Version nothing appears,
>>>> instead the console turns white and thecursor turns blue ( busy)
>>>> and I know nothing about the progress of the running code.
>>>>
>>>> I just want to see the bar and the output of the print function as
>>>> I used to, any help?
>>>>
>>>> Thanks in advance.
>>>> Maram Salem
>>>>
>>>>
>>>>
>>>> Sent from my iPhone
>>>>
>>>>> On Nov 3, 2016, at 8:30 PM, jim holtman <jholtman at gmail.com> wrote:
>>>>>
>>>>> A little more information would help. How exactly are out
>>>>> creating the output to the console? Are you using 'print', 'cat'
>>>>> or something else? Do you have buffered output checked on the GUI
>>>>> (you probably don't want it checked or you output will be delayed
>>>>> till the buffer is full -- this mightbe the cause of your problem.
>>>>>
>>>>>
>>>>> Jim Holtman
>>>>> Data Munger Guru
>>>>>
>>>>> What is the problem that you are trying to solve?
>>>>> Tell me what you want to do, not how you want to do it.
>>>>>
>>>>>> On Thu, Nov 3, 2016 at 1:55 PM, Maram SAlem
>>>>>> <marammagdysalem at gmail.com> wrote:
>>>>>> Hi all,
>>>>>>
>>>>>> I've a question concerning the R 3.3.1 version. I have a long
>>>>>> code that I used to run on versions earlier to the 3.3.1 version,
>>>>>> and when I copied the code to the R console, I can still see the
>>>>>> code while the loop is executing , along with the output printed
>>>>>> after each iteration of the loop.
>>>>>>
>>>>>> Now, on the 3.3.1 version, after I copy the code to the console,
>>>>>> it disappears and I only see the printed output of only one
>>>>>> iteration at a time, that is, after the first iteration the
>>>>>> printed output disappears ( thoughit's only 6 lines, just giving
>>>>>> me some guidance, not a long output).
>>>>>> This is causing me some problems, so I don't know if there is a
>>>>>> general option for R that enables me to still see the code and
>>>>>> the output of allthe iterations till the loop is over, as was the
>>>>>> case with earlier R versions.
>>>>>>
>>>>>> I didn't include the code as it's a long one.
>>>>>>
>>>>>> Thanks a lot in advance,
>>>>>>
>>>>>> Maram
>>>>>>
>>>>>>
>>>>>> Sent from my iPhone
>>>>>> ______________________________________________
>>>>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>> PLEASE do read the posting guide
>>>>>> http://www.R-project.org/posting-guide.html
>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>> [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
--
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
Disclaimer: Views expressed in this email are those of the individual and do not necessarily represent official views of the European Commission.
More information about the R-devel
mailing list