Skip to content

R CMD BATCH --vanilla --slave produces unwanted lines

3 messages · robin hankin, Thomas W Blackwell, David Brahm

#
Hello list

(thanks for all the help on my data.frame() question, especially to
Professor R for a working script...I was pleased to see the solution
wasn't obvious!)

Anyway, now I'm trying to run R in batch mode, but I'm getting extra
output, which I don't want (RedHat 8.3, R-1.7.0):

r:~% cat test.R
options(echo=FALSE)
write(rnorm(4),"")

r:~% R CMD BATCH --vanilla --slave test.R
r:~% cat test.Rout
0.1500393 0.1067567 0.2707306 -1.657154
[1] 1.82 0.07 1.87 0.00 0.00
r:~% 


I just want the four random variables, not the "options(echo=FALSE)"
line nor the final line which looks like the output of a proc.time()
call (how come this is called at all if I'm using the --vanilla flag?)

How do I arrange for test.Rout to contain just a single line of four
random variables?
#
Supply a separate output file name explicitly to write().

-  tom blackwell  -  u michigan medical school  -  ann arbor  -
On Fri, 30 May 2003, Robin Hankin wrote:

            
#
Robin Hankin <r.hankin at auckland.ac.nz> wrote:

            
...
Why not just run:
unix> R --vanilla --slave < test.R > test.out

Then the "options(echo=FALSE)" line is unnecessary.  Note an explicit q()
at the end of the script eliminates a single blank line that occurs otherwise.
So the test.R script is just:

  write(rnorm(4),"")
  q()