From: ripley@stats.ox.ac.uk
Date: Sat 15 Jun 2002 - 16:57:32 EST
Message-id: <Pine.LNX.4.31.0206150755280.23922-100000@gannet.stats>
On Fri, 14 Jun 2002, Vadim Ogranovich wrote:
> 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?
Use it as documented:
cat("i=", i, "\n", file=stderr())
-- Brian D. Ripley, ripley@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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:57:26 EST