
Last chance! 50% off unlimited learning
Sale ends in
Arguments to a script are those following the --args
argument.
opt_get_args(opts = commandArgs())
character; vector of arguments, (Default: commandArgs()
)
Returns the user provided arguments, i.e. those following (the first)
--args
flag. This is identical to what is done by
commandArgs( trailingOnly = TRUE )
does. This is included an used
since it supports testing/modifying the commandArgs
array.
character; vector stripping elements preceding and
including (the first) --args
flag.
# NOT RUN {
opt_get_args()
opt_get_args( opts=c( "Rscript", "-a", "-b", "--args", "-c", 3, "-d" ) ) # "-c" "3" "-d"
opt_get_args( opts=c( "-a", "-b", "--args", "-c", "--args", "-d" ) ) # "-c" "-d"
opt_get_args( opts=c( "--foo", "bar") )
# }
Run the code above in your browser using DataLab