command line arguments in bash to Rscript
Just a guess, perhaps you need to convert CorrAns
from character to numeric, since Value section of ?CommandArgs
says:
A character vector containing the name of the executable and the user-supplied command line arguments.
UPDATE: It could be as easy as:
#!/bin/Rscriptargs <- commandArgs(TRUE)(CorrAns = args[1])(CorrAns = as.numeric(args[1]))
Reading the docs, it seems you might need to remove the TRUE
from the call to commandArgs()
as you don't call the script with --args
. Either that, or you need to call Rscript Graphs.R --args 10
.
Usage
commandArgs(trailingOnly = FALSE)
Arguments
trailingOnly
logical. Should only arguments after--args
be returned?