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
checkArg(
x,
cl,
s4 = FALSE,
len,
min.len,
max.len,
choices,
subset,
lower = NA,
upper = NA,
na.ok = TRUE,
formals
)
Nothing.
[any]
Argument.
[character
]
Class that argument must “inherit” from.
If multiple classes are given, x
must “inherit” from at least one of these.
See also argument s4
.
[logical(1)
]
If TRUE
, use is
for checking class cl
, otherwise use inherits
, which
implies that only S3 classes are correctly checked. This is done for speed reasons
as calling is
is pretty slow.
Default is FALSE
.
[integer(1)
]
Length that argument must have.
Not checked if not passed, which is the default.
[integer(1)
]
Minimal length that argument must have.
Not checked if not passed, which is the default.
[integer(1)
]
Maximal length that argument must have.
Not checked if not passed, which is the default.
[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.
[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.
[numeric(1)
]
Lower bound for numeric vector arguments.
Default is NA
, which means not required.
[numeric(1)
]
Upper bound for numeric vector arguments.
Default is NA
, which means not required.
[logical(1)
]
Is it ok if a vector argument contains NAs?
Default is TRUE
.
[character
]
If this is passed, x
must be a function.
It is then checked that formals
are the names of the
(first) formal arguments in the signature of x
.
Meaning checkArg(function(a, b), formals = "a")
is ok.
Default is missing.