Dear R wizards---I read Brian Ripley's post from 2004 which said that it was not possible to print to STDERR. Alas, I have more modest needs. I was wondering if it was possible to just send a string to STDERR with cat() while in CMD BATCH mode. Is it not possible to open STDERR in R? (Or does R use STDERR for itself and redirect it into the output stream?) This would be on a standard Unix (gentoo) system and R 2.4.x. /iaw
ivo welch wrote:> Dear R wizards---I read Brian Ripley's post from 2004 which said that > it was not possible to print to STDERR. Alas, I have more modest > needs. I was wondering if it was possible to just send a string to > STDERR with cat() while in CMD BATCH mode. > > Is it not possible to open STDERR in R? (Or does R use STDERR for > itself and redirect it into the output stream?) > > This would be on a standard Unix (gentoo) system and R 2.4.x. > >$ echo 'sink(stderr());cat("Goodbye, cruel World!\n");sink()' | R -q --vanilla 2> tictactoe> sink(stderr());cat("Goodbye, cruel World!\n");sink()$ cat tictactoe Goodbye, cruel World! -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
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... sincerely, /ivo welch On 4/20/07, ivo welch <ivowel at gmail.com> wrote:> thank you, peter and brian. I had not found the stderr() function. > (I had looked at the R Input/Output guide.) This is great. regards, > /ivo >