[R-SIG-Mac] Flushing the buffer?
Simon Urbanek
simon.urbanek at r-project.org
Sat Jun 30 11:11:46 CEST 2007
Try cat(r, "\n") ...
Cheers,
S
On Jun 25, 2007, at 2:24 AM, Rolf Turner wrote:
>
>
> Please reply to me directly since I don't subscribe to this list.
>
> I am using an Imac, to which I am relatively new, and have
> encountered somewhat puzzling behaviour.
> I wrote a script to source in order to do a simulation, and put in a
> ``cat'' statement in a for-loop to
> let me know how things were progressing. The strange behaviour was
> that the output from the
> ``cat()s'' seemed to be buffered, and did not appear on the screen
> until the whole procedure
> completed. Which is pretty useless.
>
> The funny thing is I'm pretty sure that I did exactly the same thing
> last week, and the buffering
> behaviour did not occur. I don't *think* I changed any settings, but
> something must have changed.
> Can anyone suggest how I might change things back or otherwise over-
> ride the buffering.
> I tried putting in a call to flush.console(), but that has no effect.
>
> The output from sessionInfo() is as follows:
>
> R version 2.5.0 (2007-04-23)
> i386-apple-darwin8.9.1
>
> locale:
> C
>
> attached base packages:
> [1] "stats" "graphics" "grDevices" "utils" "datasets"
> "methods"
> [7] "base"
>
> other attached packages:
> misc
> "0.0-1"
>
> One other thing: If I replace the cat() statements by print()
> statements, then the buffering
> does not seem to occur. This strikes me as very weird.
>
> Here is a toy example:
>
> for(r in 1:20) {
> X <- sum(rnorm(1e6))
> cat(r,"")
> }
> cat("\n")
>
> The buffering phenomenon occurs whether I put the forgoing code in a
> file and source that file,
> or type the code directly into the console.
>
> Any ideas? Thanks.
>
> cheers,
>
> Rolf Turner
>
> ######################################################################
> Attention:\ This e-mail message is privileged and confidenti...
> {{dropped}}
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
More information about the R-SIG-Mac
mailing list