[R] R command line usage

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 28 08:44:59 CET 2008

On Sun, 27 Jan 2008, Deepak Chandran wrote:

> Hello,
>    Usually if I want to run R code from another program, I generate an
> R script and run R BATCH. However, I have been wanting to access R's
> command line from another program. In other words, I want the std output
> from another program to feed into R (command line). Is there any way to
> do that? I would also like to collect R's response using std input.

You haven't told us your OS (see the posting guide), but 'R CMD BATCH' is 
for batch use which this is not. On Unix, use R directly, on Windows use 

On both systems pipes work in a decent shell, so you can do things like

prog1 | R --slave | prog2

or you can use Rscript.

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