I have a R script and I would like to pass some filenames/parameters to my Rscript and to execute it from a terminal. I used this command:
fileA='aaaa.txt'
fileB='bbbb.txt'
n=100
string='hello'
R CMD BATCH --vanilla '--args $fileA $fileB $n $string' Rscript_file.R
I added this line in my Rscript_file.R file:
args <- commandArgs(trailingonly=TRUE)
but I got this error:
> args <- commandArgs(trailingonly=TRUE)
Error in commandArgs(trailingonly = TRUE) :
unused argument (trailingonly = TRUE)
Execution halted
Any ideas? thanks