[R] "displayed" output of cat(..., stderr()) is garbaged

Vadim Ogranovich vograno at arbitrade.com
Sat Jun 15 03:47:36 CEST 2002


Dear R-users,

To display progress of a loop I wanted to print the current value of the
loop variable, e.g.

> for (i in 1:2) cat("i=", i, "\n")
for (i in 1:2) cat(i, "\n")
i= 1 
i= 2 


So far so good. Now I want to redirect it to stderr() (to make it
unbuffered)

> for (i in 1:2) cat("i=", i, "\n", stderr())
for (i in 1:2) cat("i=", i, "\n", stderr())
i= 1 
 2i= 2 
 2> 

This is contaminated with the value of the stderr file descriptor (2).

Is there any way to get rid of this "garbage"? Is there any other way to
write to stderr?

Thanks, Vadim

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