logger.argument: logger.argument

Description Usage Arguments Details Value Author(s) Examples

View source: R/logger.R

Description

Reads a command-line argument supplied to a script.

Usage

1
2
3
4
5
6
7
8
logger.argument(
  arg.names,
  full.name,
  arg.type = "character",
  accepted.values = NULL,
  default = NULL,
  arg.list = commandArgs()
)

Arguments

arg.names

character vector of acceptable argument names. This function scans the provided arguments and performs a case insensitive match.

full.name

One-element character vector giving the argument's full name or description. This is used in a log message in case of an error.

arg.type

Variable type of the argument. Must be one of "character", "logical", "integer", "double", "numeric" or "real". The last three types are all synonyms.

accepted.values

Vector of accepted values for the argument. This must be of the type given in arg.type. Set this to NULL if there are no restrictions on the argument values.

default

Default value for the argument in case it is not specified. Setting this to NULL makes the argument required, that is, an error is generated if the argument is not specified. Set this to NA if is not a required argument and it shouldn't default to a specific value. Otherwise, if accepted.values is provided, this must be one of its elements.

arg.list

Vector of arguments provided at the execution of the script. The arguments should be provided as name=value pairs.

Details

This is convenience function for reading parameters supplied to the script in the form name = value. It expects that logging is enabled (see rnb.options). The function fails if this condition is not met.

Value

Argument's value, or NULL if such is not provided.

Author(s)

Yassen Assenov

Examples

1
2
3
n.iterations <- logger.argument("iterations", "number of iterations", "integer",
  accepted.values = 1:100, default = 1L)
logger.close()

RnBeads documentation built on March 3, 2021, 2 a.m.