I have been using R CMD BATCH my_script.R
from a terminal to execute an R
script. I am now at the point where I would like to pass an argument to the command, but am having some issues getting it working. If I do R CMD BATCH my_script.R blabla
then blabla
becomes the output file, rather than being interpreted as an argument available to the R script being executed.
I have tried Rscript my_script.R blabla
which seems to pass on blabla
correctly as an argument, but then I don't get the my_script.Rout
output file that I get with R CMD BATCH
(I want the .Rout
file). While I could redirect the output of a call to Rscript
to a file name of my choosing, I would not be getting the R input commands included in the file in the way R CMD BATCH
does in the .Rout
file.
So, ideally, I'm after a way to pass arguments to an R script being executed via the R CMD BATCH
method, though would be happy with an approach using Rscript
if there is a way to make it produce a comparable .Rout
file.