This is a command-line argument parser which wraps the powerful Perl module
Getopt::Long and with some adaptations for easier use in R. It also provides a simple way for variable interpolation in R.
There are two vignettes in the package which explain in more detail:
The package can be installed from CRAN:
or directly from GitHub:
This package wraps the powerful Perl module
Getopt::Long and keeps almost all features of it. The syntax of option specification is the same as
Getopt::Long. So if you are from Perl and you know
Getopt::Long, there would be no difficulty with using it.
The usage is very simple:
library(GetoptLong) cutoff = 0.05 GetoptLong( "number=i", "Number of items.", "cutoff=f", "Cutoff for filtering results.", "verbose!", "Print message." )
Then you can run this script by:
~\> Rscript foo.R --number 4 --cutoff 0.01 --verbose ~\> Rscript foo.R --number=4 --cutoff=0.01 --no-verbose ~\> Rscript foo.R -n 4 -c 0.01 -v ~\> Rscript foo.R -n 4 --verbose
Help message is automatically generated:
Usage: Rscript foo.R [options] Options: --number, -n integer Number of items. --cutoff, -c numeric Cutoff for filtering results. [default: 0.05] --verbose Print message. --help, -h Print help message and exit. --version Print version information and exit.
This package also supports simple variable interpolation, which means you can embed variables into texts directly, just like in Perl.
So it would be much easier for you to construct complicated texts instead of using