Throws exception if checks are not passed. Note that argument is evaluated when checked.
This function is superseded by the package checkmate and might get deprecated in the future. Please
Usage
checkArg(
x,
cl,
s4 = FALSE,
len,
min.len,
max.len,
choices,
subset,
lower = NA,
upper = NA,
na.ok = TRUE,
formals
)Arguments
- x
[any]
Argument.- cl
[
character]
Class that argument must “inherit” from. If multiple classes are given,xmust “inherit” from at least one of these. See also arguments4.- s4
[
logical(1)]
IfTRUE, useisfor checking classcl, otherwise useinherits, which implies that only S3 classes are correctly checked. This is done for speed reasons as callingisis pretty slow. Default isFALSE.- len
[
integer(1)]
Length that argument must have. Not checked if not passed, which is the default.- min.len
[
integer(1)]
Minimal length that argument must have. Not checked if not passed, which is the default.- max.len
[
integer(1)]
Maximal length that argument must have. Not checked if not passed, which is the default.- choices
[any]
Discrete number of choices, expressed by a vector of R objects. If passed, argument must be identical to one of these and nothing else is checked.- subset
[any]
Discrete number of choices, expressed by a vector of R objects. If passed, argument must be identical to a subset of these and nothing else is checked.- lower
[
numeric(1)]
Lower bound for numeric vector arguments. Default isNA, which means not required.- upper
[
numeric(1)]
Upper bound for numeric vector arguments. Default isNA, which means not required.- na.ok
[
logical(1)]
Is it ok if a vector argument contains NAs? Default isTRUE.- formals
[
character]
If this is passed,xmust be a function. It is then checked thatformalsare the names of the (first) formal arguments in the signature ofx. MeaningcheckArg(function(a, b), formals = "a")is ok. Default is missing.