[R] cat function within a loop

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Oct 5 17:15:12 CEST 2004


If perchance you are using Windows (and specifically Rgui) and not telling 
us (as the posting guide asks you to), do read the rw-FAQ Q6.3 (as the 
posting guide also asks you to).

On Tue, 5 Oct 2004, Tatsuki Koyama wrote:

> I have a 'cat' function within a for loop.
> I would like it to print out the result everytime it goes through the
> for loop so that I can monitor the progress, but it only prints out
> (execute the cat function) once at the very end of the for loop.

Have you evidence for that or are you speculating?  When I run your 
example I get a line for every i.  If you do not, something is wrong with 
your (unspecified) installation of R.

> A simple example:
> 
> for(i in 1:100000){
> 	cat(i, '\n')
> }
> 
> What should I do in order for the cat function to be executed
> everytime it goes thorough the for loop?

> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
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