[R] passing command line arguments to 'R CMD BATCH myScript.R'
Uwe Ligges
ligges at statistik.uni-dortmund.de
Fri Feb 25 16:59:09 CET 2005
Oleg Sklyar wrote:
> Hi Community,
>
> I have a question about how to pass command line parameters to R script
> running in the batch mode. The problem is: there is a banch of data
> files which are to be processed by R script called from a web-server,
> i.e. in the batch mode. The web server generates data files and passes
> their names calling 'R CMD BATCH' one by one for every file. Now the
> question is how to call 'R CMD BATCH myScript.R' with parameters, like
> file name to process? I know how to read the parameters passed to an R
> script, but I don't know how to pass them.
>
> There is an option --args that should cut the rest of the line off the
> command line. The problem is however that BATCH syntax is: 'R CMD BATCH
> [options] inFile [outFile]', i.e. if I write
> 'R CMD BATCH --args myDataFile myScript.R' or 'R CMD BATCH --args
> myDataFile < myScript.R' (similar was posted on some R help under
> Windows) it is not going to work because then BATCH doesn't know about
> myScript.R - it is considered as a parameter, so only 'R CMD BATCH' is
> executed. If however I use 'R CMD BATCH myScript --args myDataFile' then
> R understands --args as an output file and generates a file with that name.
>
> Does anyone has a solution for the problem?
>
> Best regards
> Oleg
>
See ?commandArgs
Uwe Ligges
More information about the R-help
mailing list