[R] cat() to STDERR

Dirk Eddelbuettel edd at debian.org
Sat Apr 21 16:21:10 CEST 2007


On 21 April 2007 at 09:16, ivo welch wrote:
| I spoke to soon.  cat("hello", file=stderr()) does not "punch through"
| R CMD BATCH test.R.  Is there a way to have stderr() messages escape
| the log and go directly to the invoking terminal (i.e., under
| linux/unix, late-release gentoo).  Maybe this should require a
| different name than "BATCH", so as to not break scripts that rely on
| nothing escaping.  I find it very convenient in long scripts written
| in perl or C to have the ability to write "blips" to the terminal,
| too...

Works for me using our 'little r' aka littler tool:

edd at basebud:~> r -e 'cat("Hello stderr\n", file=stderr()); cat("Hello stdout\n")' > /tmp/ivo.txt
Hello stderr
edd at basebud:~> cat /tmp/ivo.txt
Hello stdout
edd at basebud:~> 

So capture stdout as one commonly does, yet stderr comes through for alerts.

Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison



More information about the R-help mailing list