I'm having a hard time passing a filename to my R script. The file is a csv file with the batch parameters for multiple runs of the script. I am trying to include it here so that the user does not need to edit the R script in order to specify the location of that file.
My Windows command line syntax is:
R CMD BATCH --slave "--args fn=batch.csv" myscript.r output.txt
The closest I have gotten to retrieving this in my R script is by doing:
eval(parse(file=commandArgs()[8])))
batch_args = read.table(fn, sep=",")
I have experimented with commandArgs(trailingOnly=TRUE)
and parse(text=commandArgs()[8])
, etc., with no luck. Most of the documentation that I have seen does not apply specifically to passing filenames. Can anyone think of a solution?