| make_option {optparse} | 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 = "store", type = NULL, dest = NULL, default = NULL, help = "", metavar = NULL) add_option(object, opt_str, action = "store", type = NULL, dest = NULL, default = NULL, help = "", metavar = NULL)
opt_str |
A character vector containing the string of the desired long flag comprised of “–” followed by a letter and then a sequence of alphanumeric characters and optionally a string of the desired short flag comprised of the “-” followed by a letter. |
action |
A character string that describes the action |
type |
A character string that describes specifies which data type
should be stored, either “logical”, “integer”, “double”,
“complex”, or “character”. Default is “logical” if
|
dest |
A character string that specifies what field in the list returned
by |
default |
The default value |
help |
A character string describing the option to be used by
|
metavar |
A character string that stands in for the option argument when
printing help text. Default is the value of |
object |
An instance of the |
Both make_option and add_option return instances of
class OptionParserOption.
Trevor Davis.
Python's optparse library, which inspires this package,
is described here: http://docs.python.org/library/optparse.html
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]")