[R] Forcing a refresh in R for Windows

Jim_Garrett@bd.com Jim_Garrett at bd.com
Wed Sep 26 20:44:32 CEST 2001

System:  Windows NT 4.0 450 MHz Pentium II, R version 1.3.0 (will upgrade

Is there some way to force the command-line interface to print information
to the screen before evaluating the next expression?  For example, if I put
the following in a file:

cat("Select a file\n")
filename <- file.choose()

and source the file, I don't see the instruction "Select a file" until
after I'm done with the dialog box that pops up.

Another example involves getting updates from an iterative procedure before
the procedure is done:

for(i in 1:500)
#  if(i %% 10 == 0)
    cat("iteration ", i, "\n")
  # <something time-consuming here>

I don't get any update printed to the screen until after the loop is
completed, which is when I no longer need it.  If something causes the
screen to refresh, such as swapping to another application and back, the
information is printed.  However, is there any kind of programming command
I can use that will force a printout when I want it?


Jim Garrett
Becton Dickinson Diagnostic Systems
Baltimore, Maryland, USA

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list