
Last chance! 50% off unlimited learning
Sale ends in
This is a programmer's utility function to check whether the argument is a numeric vector of the correct length.
check.nvector(v, npoints = NULL, fatal = TRUE, things = "data points",
naok = FALSE, warn = FALSE, vname, oneok = FALSE)
A logical value indicating whether all the requirements were
satisfied. If FALSE
, then this value has an attribute
"whinge"
, a character string describing the requirements that
were not satisfied.
The argument to be checked.
The required length of v
.
Logical value indicating whether to stop with an error message
if v
does not satisfy all requirements.
Character string describing what the entries of v
should
correspond to.
Logical value indicating whether NA
values are permitted.
Logical value indicating whether to issue a warning
if v
does not satisfy all requirements.
Character string giving the name of v
to be used in messages.
Logical value indicating whether v
is permitted to have
length 1.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au.
This function checks whether v
is a numeric vector with
length equal to npoints
(or length equal to 1 if
oneok=TRUE
), not containing any NA
values (unless
naok=TRUE
).
If these requirements are all satisfied, the result is the logical
value TRUE
.
If not, then if fatal=TRUE
(the default), an error occurs;
if fatal=FALSE
, the result is the logical value FALSE
with an attribute describing the requirement that was not satisfied.
check.anyvector
,
check.nmatrix
,
check.1.real
, check.named.vector
.
z <- 1:10
check.nvector(z, 5, fatal=FALSE)
y <- 42
check.nvector(y, 5, fatal=FALSE, oneok=TRUE)
Run the code above in your browser using DataLab