check.anyvector {spatstat.utils} | R Documentation |
Check For Vector or Factor With Correct Length
Description
This is a programmer's utility function to check whether the argument is a vector or factor of the correct length.
Usage
check.anyvector(v, npoints = NULL, fatal = TRUE, things = "data points",
naok = FALSE, warn = FALSE, vname, oneok = FALSE)
Arguments
v |
The argument to be checked. |
npoints |
The required length of |
fatal |
Logical value indicating whether to stop with an error message
if |
things |
Character string describing what the entries of |
naok |
Logical value indicating whether |
warn |
Logical value indicating whether to issue a warning
if |
vname |
Character string giving the name of |
oneok |
Logical value indicating whether |
Details
This function checks whether v
is a vector or factor 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.
Value
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.
Author(s)
Adrian Baddeley Adrian.Baddeley@curtin.edu.au.
See Also
check.nvector
,
check.nmatrix
,
check.1.real
, check.named.vector
.
Examples
z <- factor(letters[1:10])
y <- z[1]
check.anyvector(z, 5, fatal=FALSE)
check.anyvector(y, 5, oneok=TRUE)
check.anyvector(42, 5, fatal=FALSE)