[R] R command line arguments
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Jan 5 07:41:29 CET 2008
On Fri, 4 Jan 2008, Bernd Jagla wrote:
> Hi,
>
> I would like start R in BATCH mode and submit my own parameters. Or in other
> words, I would like to specify variables from the command line and execute a
> script using those.
>
> I have been looking at commandArgs and calling R from the command line under
> bash:
>
> R CMD BATCH --no-save --args -filename="$filname" -- r-test.R r-test.Rout
>
> The problem here is, if $filename contains a space it is regarded as a new
> parameter which makes it more difficult to parse.
On a Unix-alike and not Windows, I presume. You need to double quote the
variable.
> Also, are there function that help parse the parameters?
?commandArgs, as you have mentioned.
> Or, is there a totally different this is usually done in R?
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