Dear Professor Ripley,

Firstly, thank you very much for your advice. I was not aware my R was so
old. Sorry I must have missed the instruction on reading the posting
guidelines.

I have updated it and it now runs again. This is a big step forward. However
it is not running properly (or I am doing something wrong).

There are still two problems may I ask for your help with please?

1. When I call the script it fails with the following message in the output
file:

> ##First read in the arguments listed at the command line
> args <- commandArgs(TRUE)
Error in commandArgs(TRUE) : unused argument(s) (TRUE)
Execution halted

2. The diagnostic details (that should be going to test01b.ROUT are now
going to strange places, overwriting the test01b.R file if I do not include
the < and > redirectors.

I am now using the following syntax, from the manual:

Rcmd BATCH --no-save --no-restore --args parms=c(1,2,3) < test01b.R >
test01b.ROUT

Currently it is writing the output to "parms=c(1,2,3).ROUT"

This is attached but says "fatal error cannot open file "--args"

The file test01b.ROUT is created but empty.

I get the same results if I start it with R CMD BATCH ...

Is the a difference between R CMD... and Rcmd... please? The manual is not
very clear on this.

I am sorry to impose on you but guess I am still doing something wrong. I
have looked through the documentation but cannot find much on this or many
examples.

Many thanks,

Andrew Hicks


-----Original Message-----
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] 
Sent: 10 January 2009 18:18
To: Andrew Hicks
Cc: r-help@r-project.org
Subject: Re: [R] Arguments for Rcmd BATCH

Your R is far too old, and in particular too old for the example you 
are trying.

Please do you as asked in the posting guide to do before posting, and 
upgrade.  Then you will have Rscript, as described in the current 'An 
Introduction to R' manual for this purpose (with examples).

On Sat, 10 Jan 2009, Andrew Hicks wrote:

> Sorry to bother you and I hope this will be easy to solve.
>
>
> I am trying to run R scripts in batch, called from another programme,
under
> Windows XP. I have R 2.4.1
>
>
>
> I need to be able to pass a list of numeric arguments to the script as
well.
>
>
>
> The Rscript and its input data file are attached.
>
>
>
> I have been trying the syntax below but it doesn't work:
>
>
>
> Rcmd BATCH -no-save -no-restore -args parms=c(1,2,3) test01b.R
>
>
>
> (each of these BATCH options is preceded by 2 - characters, but my Outlook
> is munging them together here)
>
>
>
> The script then accesses (or tries to) the variables as parms[1],
parms[2],
> etc.
>
>
>
> I get the respose "unable to open input file" at the command line and no
> other diagnostic output.
>
>
>
> I got this syntax from p85 of the R-Intro doc and from the website
> http://quantitative-ecology.blogspot.com/search/label/scripts. I could not
> find any other illustrations or instructions of how to use args with
BATCH.
>
>
>
> Without using any parameter args it otherwise runs fine.
>
>
>
> Please can you advise what am I doing wrong and how should this command be
> structured? Do I also need to change the way the script is accessing the
> arguments?
>
>
>
> Many thanks,
>
>
>
> Andrew Hicks
>
>

-- 
Brian D. Ripley,                  rip...@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
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to