[R] capture stderr in Windows

Duncan Murdoch murdoch at stats.uwo.ca
Mon Aug 16 19:57:31 CEST 2004


I wrote the message below, but it's just plain wrong.

The CMD.EXE shell in Win XP (and 2K?) allows redirection of stderr in
the usual Unix style:

  Rterm --no-save --no-restore < "Rscriptfile" > "Rstdoutfile"
2>"Rstderrfile"

You can also use "2>&1" to redirect stderr into the stdout stream, so
both go to Rstdoutfile.

Duncan Murdoch


>On Mon, 16 Aug 2004 10:25:08 -0700, "Moises Hassan" <mhassan at scitegic.com> wrote :
>
>>I'm using the following command to run R in Windows
>>
>> 
>>
>>"Rterm --no-save --no-restore < "Rscriptfile" > "Rstdoutfile"
>>
>> 
>>
>>How can I capture the text sent by R to stderr in a file?
>
>That depends on your shell.  The standard Windows command shell COMMAND.COM or CMD.EXE provides no easy way to do this.  There are lots of replacement shells around that can do it; I use Cygwin's bash shell most of the time.
>
>There are also programs on the net that do nothing but redirect standard handles, e.g. <http://www.commandline.co.uk/mtee/index.html>. I've never tested these.
>
>Duncan Murdoch




More information about the R-help mailing list