[R] passing of arguments to R CMD BATCH in bash script that is submitted to torque (Linux platform)

Franckx Laurent laurent.franckx at vito.be
Sat Jun 15 10:45:55 CEST 2013


Dear all

I want to call R repeatedly in batch mode from a bash script that is then submitted to torque.

My calls to R depend on optional arguments.

When I introduce these arguments as literals, the calls work fine, for instance:

R CMD BATCH  --no-save "--args PERIOD='08' YEAR='2008' SC='BAU' " preparecostvectors.R

However, the arguments PERIOD, YEAR and SC are really variables over which I 'loop'.

When these variables are defined in the same script as the call to R CMD BATCH, this still works, for instance:

year="2008"
sc="BAU"
R CMD BATCH  --no-save "--args PERIOD='08' YEAR=\"$year\" SC=\"$sc\"  " preparecostvectors.R

Things go wrong when the script is called from another script, for instanced with:

qsub -v year="2008",sc="BAU"  ATLAS_assign.sh

"echo $sc" and "echo $year" in ATLAS_assign.sh yield "BAU" and "2008" respectively.

Thus, as far as I can see, nothing goes wrong in the passing of the optional arguments in qsub.

However,

R CMD BATCH  --no-save "--args PERIOD='08' YEAR=\"$year\" SC=\"$sc\"  " preparecostvectors.R

is not executed. I do not get even an Rout file, so I suppose the R script is not even called.

I suppose there is something wrong in the format in which I submit year and sc, but I do not see what.


Laurent Franckx, PhD
VITO NV
Boeretang 200, 2400 MOL, Belgium
Tel. + 32 14 33 58 22
Skype: laurent.franckx
laurent.franckx at vito.be
Visit our website: www.vito.be/english and http://www.vito.be/transport











[http://www.vito.be/e-maildisclaimer/vito.png]


Ontdek hoe VITO de transitie naar een duurzame maatschappij op gang trekt: www.vito.be/duurzaamheidsverslag2012<http://www.vito.be/duurzaamheidsverslag2012>
Discover how VITO initiates the transition towards a sustainable society: www.vito.be/sustainabilityreport2012<http://www.vito.be/sustainabilityreport2012>


VITO Disclaimer: http://www.vito.be/e-maildisclaimer



More information about the R-help mailing list