[R] R CMD BATCH w/o inputs?
Marc Schwartz
MSchwartz at mn.rr.com
Tue Mar 14 03:02:50 CET 2006
On Mon, 2006-03-13 at 20:17 -0500, ivo welch wrote:
> dear R wizards---I must be standing on the line (German
> translation---this must be obvious). This is probably embarrassingly
> obvious to anyone, except to me right now. maybe it is late.
>
> I would like to run my R code in batch, but not see the R compilations
> and my R source code---I just want to see the same output that I would
> see if I ran source("i.R"), but direct it to a file. I can of course
> direct R output to a file ($ R > myoutput), and then type the source
> and exit statements blindly, but there must be a better way---I just
> don't know it.
>
> what am I missing?
>
> regards,
>
> /iaw
Something like this, which is covered in section "B.1 Invoking R from
the command line" in An Introduction to R:
http://cran.r-project.org/doc/manuals/R-intro.html#Invoking-R
# First you have a text file with R commands, say 'add.R',
# which contains:
1 + 2
# You want to have R take its input from the above file
# and output the result to a text file called 'addout.txt'
# Note the options 'vanilla' and 'slave':
R --vanilla --slave < add.R > addout.txt
The contents of 'addout.txt' will be:
[1] 3
Is that what you were looking for?
HTH,
Marc Schwartz
More information about the R-help
mailing list