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:
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."
)
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.
Variable interpolation
This package also supports simple variable interpolation, which means you
can embed variables into texts directly, just like in Perl.
r = c(1, 2)
value = 4
name = "name"
qq("region = (@{r[1]}, @{r[2]}), value = @{value}, name = '@{name}'")
## [1] "region = (1, 2), value = 4, name = 'name'"
So it would be much easier for you to construct complicated texts instead of
using paste().
GetoptLong
This is a command-line argument parser which wraps the powerful Perl module
Getopt::Longand 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:
Install
The package can be installed from CRAN:
or directly from GitHub:
Usage
Control command line options
This package wraps the powerful Perl module
Getopt::Longand keeps almost all features of it. The syntax of option specification is the same asGetopt::Long. So if you are from Perl and you knowGetopt::Long, there would be no difficulty with using it.The usage is very simple:
Then you can run this script by:
Help message is automatically generated:
Variable interpolation
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
paste().License
MIT @ Zuguang Gu