[R] cat() to STDERR
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Apr 21 16:14:15 CEST 2007
On Sat, 21 Apr 2007, 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...
Well, R CMD BATCH sends STDERR to the file (the help does say
Description:
Run R non-interactively with input from 'infile' and send output
(stdout/stderr) to another file.
) but look at the script: in 2.4.1 Unix-alikes
cat ${in} | ${R_HOME}/bin/R ${opts} ${R_BATCH_OPTIONS} >${out} 2>&1
is the key part. So
R --vanilla < infile > outfile
is likely to do what you want.
In 2.5.0 Rscript is even easier to use.
> 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
>>
>
--
Brian D. Ripley, ripley at 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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list