[R] cat function within a loop
Sundar Dorai-Raj
sundar.dorai-raj at PDF.COM
Tue Oct 5 17:01:40 CEST 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.
> 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?
> Thanks!
>
You haven't told us what operating system you're using. But I bet it's
Windows and what you're seeing is the buffered output. If that's the
case see the Windows FAQ 6.3.
http://cran.r-project.org/bin/windows/rw-FAQ.html
--sundar
More information about the R-help
mailing list