Stats Explorer

Irregular comments on R, visualization and statistical computing

No stringrs attached

I just uploaded version 0.6 of docopt to CRAN, which was long overdue.

Docopt is a R package that helps in parsing command-line options of a R-script. The beauty of docopt is that it uses the help text (i.e. “-h”) as its specification, and then docopt uses this to create a command-line argument parser.

'usage: my_prog.R [-a -r -m <msg>]

options:
 -a        Add
 -r        Remote
 -m <msg>  Message' -> doc

# load the docopt library
library(docopt)
# retrieve the command-line arguments
opts <- docopt(doc)

For more information see my useR!2014 presentation.

Besides some minor bug fixes (thanks contributors!), the most important thing is the removal of docopt’s dependency on stringr (and therefore stringi). docopt was a heavy user of str_extract and str_match, which are great. stringr is a very useful and consistent package, which I use a lot in data munging. However as a package maintainer I have other responsibilities. Besides providing useful and correct functionality a package should be stable and lean. This is especially true for docopt since its use is with Rscripts that run in batch mode. Its foot print should be kept minimal.

Thanks to base R this is possible, but I am certainly not the first to notice :-)