What workflow and tools do you all use when developing R scripts that are run on a recurring basis?
Specifically,
- What command line argument parser do you use?
- How do you version control your development and production version of the scripts? How do you iteratively debug your R logic while having confidence it will work in non-interactive mode?
For 1) I am looking for a command line argument parsers that are named, typed and come with help message. I am aware of argparse and getopt which are great but has python dependencies. aarph is very neat and creative but I want the script self-documenting from the outside. Do you think there will be interests in wrapping a C++ CLI argument parser?
For 2) How does your workflow enable you to interactively work on an R script that is run from the command line? This is mine and I am curious to learn if you have better practices. In the below example, it allows me to source and debug code interactively while letting arguments to be sourced from the command line when running with Rscript.
filename <- "test.txt"
date <- "2018-03-01"
if (!interactive()) {
args <- commandArgs(trailingOnly = TRUE)
filename <- args[0]
date <- args[1]
}
## work begins
## ...
p.s. I should acknowledge that parametrized Rmarkdown works wonders at times but sometimes I am just looking for a dull script instead of fancy reports.