Description Usage Arguments Details Author(s) Examples
Wrapper of the Perl module Getopt::Long
in R
1 2 3 | GetoptLong(..., help_head = NULL, help_foot = NULL, envir = parent.frame(),
argv_str = NULL, template_control = list(),
help_style = GetoptLong.options$help_style)
|
... |
Specification of options. The value can be a two-column matrix, a vector with even number of elements or a text template. See the vignette for detailed explanation. |
help_head |
Head of the help message when invoking |
help_foot |
Foot of the help message when invoking |
envir |
User's enrivonment where |
argv_str |
A string that contains command-line arguments. It is only for testing purpose. |
template_control |
A list of parameters for controlling when the specification is a template. |
help_style |
The style of the help messages. Value should be either "one-column" or "two-column". |
Following shows a simple example. Put following code at the beginning of your script (e.g. foo.R
):
1 2 3 4 5 6 7 8 | library(GetoptLong)
cutoff = 0.05
GetoptLong(
"number=i", "Number of items.",
"cutoff=f", "Cutoff for filtering results.",
"verbose", "Print message."
)
|
Then you can call the script from command line either by:
1 2 3 4 |
In this example, number
is a mandatory option and it should only be in
integer mode. cutoff
is optional and it already has a default value 0.05.
verbose
is a logical option. If parsing is successful, two variables number
and verbose
will be imported into the working environment with the specified
values. Value for cutoff
will be updated if it is specified in command-line.
For advanced use of this function, please go to the vignette.
Zuguang Gu <z.gu@dkfz.de>
1 2 | # There is no example
NULL
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.