Learn R Programming

optigrab (version 0.9.2.1)

opt_get_args: Return arguments to Rscript

Description

Arguments to a script are those following the --args argument.

Usage

opt_get_args(opts = commandArgs())

Arguments

opts

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.

Value

character; vector stripping elements preceding and including (the first) --args flag.

See Also

Examples

Run this code
# 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