Hi All, My R code takes very long time to finish the processing. I want to see at what stage the script is running. So I wrote some output messages using cat. But instead of displaying the cat messages at different stages they are buffered and displayed in the end when entire processing is done. Can you please suggest how to stop this buffering or some alternative way to display messages Thank you Vidhu [[alternative HTML version deleted]]
If you're using Rgui under Windows, see FAQ 7.1:> 7.1 When using Rgui the output to the console seems to be delayed. > This is deliberate: the console output is buffered ...(the FAQ says how to turn it off -- it's a menu item). Vidhu Choudhary wrote:> Hi All, > My R code takes very long time to finish the processing. I want to see at > what stage the script is running. So I wrote some output messages using cat. > But instead of displaying the cat messages at different stages they are > buffered and displayed in the end when entire processing is done. > Can you please suggest how to stop this buffering or some alternative way to > display messages > > Thank you > Vidhu > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
On Wed, 30 Apr 2008, Vidhu Choudhary wrote:> Hi All, > My R code takes very long time to finish the processing. I want to see at > what stage the script is running. So I wrote some output messages using cat. > But instead of displaying the cat messages at different stages they are > buffered and displayed in the end when entire processing is done. > Can you please suggest how to stop this buffering or some alternative way to > display messagesBy reading the R for Windows FAQ?? 7.1 When using Rgui the output to the console seems to be delayed.> > Thank you > Vidhu > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
In addition to what others have pointed to regaurding buffering and cat, there are also a couple of new functions in R 2.7.0 that help with showing the progress of computations. They are winProgressBar (windows only) and TkProgressBar (in the tcltk package). You can use these to create and update a progress bar showing how far along you are. They also have options for labels and titles that you can use to show specific messages (or just percent finished). I prefer these to cat statements because you can make the window go away and don't have the messages from cat cluttering your output. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Vidhu Choudhary > Sent: Wednesday, April 30, 2008 1:36 PM > To: r-help at r-project.org > Subject: [R] How to stop buffering of "cat" > > Hi All, > My R code takes very long time to finish the processing. I > want to see at what stage the script is running. So I wrote > some output messages using cat. > But instead of displaying the cat messages at different > stages they are buffered and displayed in the end when entire > processing is done. > Can you please suggest how to stop this buffering or some > alternative way to display messages > > Thank you > Vidhu > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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. >