Is there a way to group/tag/organize commandline arg that will be supplied to an Rscript?

16 Views Asked by At

I can get command line flags in R using the following simple setup:

library(optparse)

option_list = list(
  make_option("--flag_one", type="character", default=NULL, help="Insert help document here."),# this is where the help text is created.
  make_option("--flag_two", type="character", default=NULL, help="Insert help text here."),
  make_option("--flag_three", type="character", default=NULL, help="Insert help text here.") 
)

opt_parser = OptionParser(option_list=option_list)

args = commandArgs(trailingOnly = TRUE)
opt = parse_args(opt_parser, args=args)

I want to tag/organize/group these args. For example:

flag_one, flag_two will be for location but flag_three will be an integer value. Being able to explicitly group some flags for location (or any category) would make it easier to loop through a subset of flags.

Anyone familiar with a way to do this?

0

There are 0 best solutions below