Skip to content
Prev 31582 / 398506 Next

commandArgs()

At present there is no official way to add arguments to R: commandArgs() 
is intended to let you retrieve the standard arguments.

This has been discussed for a long time, but there are problems with doing 
it consistently across platforms: for example Windows allows an extra 
argument, the name of a .RData file, to allow file-association to work.

What you can do reliably across platforms is to pass information in 
environment variables.  Something like

NRUNS=1000 R --vanilla < test.R > test.Rout   (Unix, sh)
Rterm NRUNS=100 --vanilla < test.R > test.Rout (Windows)

and have

nruns <- as.numeric(Sys.getenv("NRUNS"))

in the script test.R
On Mon, 5 May 2003, R A F wrote:

            
There is no such mechanism at present.