[R] How to defeat buffering in Rgui?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 29 09:12:15 CEST 2012


See the posting guide: this is in the FAQ which you are expected to 
consult before posting. See

http://cran.r-project.org/bin/windows/base/rw-FAQ.html#The-output-to-the-console-seems-to-be-delayed

and ?flush.console .

On 29/06/2012 08:01, Spencer Graves wrote:
> Hello, All:
>
>
>        Does anyone know how to defeat buffering of output to the console
> from Rgui?  I routinely print progress reports to the console from
> within Rterm running under Emacs with ESS (Emacs Speaks Statistics); see
> the example below.  However, when I run the same example under Rgui, it
> queues all the output until the computations are complete.
>
>
>        How can I monitor the progress of computations in both Rgui and
> Rterm?
>
>
>        Consider the following:
>
>
> for(i in 1:1e7){
>      tst <- sin(i)
>      if((i%%1e5)==0)cat(i, "")
>      if((i%%1e6)==0)cat('\n')
> }
>
>
>        For Rterm 2.15.1 running under Emacs with ESS (Emacs Speaks
> Statistics), this prints 10000, then pauses before printing 200000,
> etc., until it gets to 1000000, printing 10 numbers in each row.
>
>
>        However, in Rgui 2.15.1, it queues all the numbers and prints
> them all together when it completes the computation.  The following is
> similar:
>
>
> for(i in 1:1e7){
>      tst <- sin(i)
>      if((i%%1e5)==0)print(i)
>      if((i%%1e6)==0)cat('\n')
> }
>
>
>> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> 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
>
>
>        Thanks,
>        Spencer


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list