I want to use RStudio to edit an R-script having command line parameters, e.g.,
my_rscript --dataset mydataset
and then to read the optiion
If you're interested in using e.g. argparser and continue developing/analyzing interactively using Rstudio, you can use the following work-around:
my_rscript and create an object args that contains all parsed input.args object to file. my_rscript from command line and specify arguments of interest. args object from file in Rstudio and continue interactivelyExample:
library("argparser")
parser <- arg_parser(description='Process commandline arguments')
parser <- add_argument(parser, arg="--dataset", type="character", help = "Dataset argument")
args = parse_args(parser)
args_file = "tempArgObjectFile.rds"
saveRDS(args, args_file); print(args); quit(); #comment this after creating args_file
args = readRDS(args_file) #use this to load during interactive development