| make_option | R Documentation |
add_option() adds a option to a prexisting OptionParser instance
whereas make_option() is used to create a list of
OptionParserOption instances that will be used in the
option_list argument of the OptionParser function to create a
new OptionParser instance.
make_option(
opt_str,
action = NULL,
type = NULL,
dest = NULL,
default = NULL,
help = "",
metavar = NULL,
callback = NULL,
callback_args = NULL,
const = NULL,
required = FALSE
)
add_option(
object,
opt_str,
action = NULL,
type = NULL,
dest = NULL,
default = NULL,
help = "",
metavar = NULL,
callback = NULL,
callback_args = NULL,
const = NULL,
required = FALSE
)
opt_str |
A character vector containing the string of the desired long
flag comprised of |
action |
A character string describing the action
If |
type |
A character string specifying which data type to store:
|
dest |
A character string specifying what field in the list returned by |
default |
The default value |
help |
A character string describing the option, used by |
metavar |
A character string that stands in for the option argument when printing help text. Default is the value of |
callback |
A function that executes after the option value is fully parsed. Its return value is assigned to the option. Arguments are: the option S4 object, the long flag string, the value of the option, the parser S4 object, and |
callback_args |
A list of additional arguments passed to |
const |
The value to store when |
required |
If |
object |
An instance of the |
Both make_option() and add_option() return instances of
class OptionParserOption.
The following classed errors may be thrown:
optparse_option_error: invalid option definition (bad flag string,
unrecognized action, etc.).
optparse_option_conflict_error: duplicate flag detected when
adding an option to a parser.
Python's optparse library, which inspires this package,
is described here: https://docs.python.org/3/library/optparse.html
parse_args() OptionParser()
make_option("--longflag")
make_option(c("-l", "--longflag"))
make_option("--integer", type = "integer", default = 5)
make_option("--integer", default = as.integer(5)) # same as previous
# examples from package vignette
make_option(c("-v", "--verbose"), action = "store_true", default = TRUE,
help = "Print extra output [default]")
make_option(c("-q", "--quietly"), action = "store_false",
dest = "verbose", help = "Print little output")
make_option(c("-c", "--count"), type = "integer", default = 5,
help = "Number of random normals to generate [default %default]",
metavar = "number")
make_option("--generator", default = "rnorm",
help = "Function to generate random deviates [default \"%default\"]")
make_option("--mean", default = 0,
help = "Mean if generator == \"rnorm\" [default %default]")
make_option("--sd", default = 1, metavar = "standard deviation",
help = "Standard deviation if generator == \"rnorm\" [default %default]")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.