read.args: read.args

Description Usage Arguments Examples

View source: R/arguments.r

Description

Read input arguments from ... with expected type and default values.

Usage

1
val <- read.args(args, key, type, defaultval)

Arguments

key

character string. This is the name of the parameter you wish to extract.

type

function or string. If a boolean-valued function like is.character, is.logical, etc., this will be used to check the type of the argument. If a string, then a standard type-checking function will be called.

args

Liste of arguments extracted from ... . Usage: inside a function first set args <- list(...);.

defaultval

Default value. Will be set, if argument is missing or is not of the correct type.

Examples

1
2
3
4
5
6
7
8
## Not run: 
f <- function(...) {
	args <- list(...);
	val <- read.args(args, key='name', type=is.character, default='N/A');
	## Rest of the function definition
};
 
## End(Not run)

RLogik/rbettersyntax documentation built on Aug. 1, 2020, 10:44 p.m.