This is a programmer's utility function to check whether the argument is a numeric vector of the correct length.
check.nmatrix(m, npoints = NULL, fatal = TRUE, things = "data points",
naok = FALSE, squarematrix = TRUE, matchto = "nrow", warn = FALSE)
The argument to be checked.
The required number of rows and/or columns for the matrix m
.
Logical value indicating whether to stop with an error message
if m
does not satisfy all requirements.
Character string describing what the rows/columns of m
should
correspond to.
Logical value indicating whether NA
values are permitted.
Logical value indicating whether m
must be a square matrix.
Character string (either "nrow"
or "ncol"
)
indicating whether it is the rows or the columns
of m
which must correspond to npoints
.
Logical value indicating whether to issue a warning
if v
does not satisfy all requirements.
A logical value indicating whether all the requirements were satisfied.
This programmer's utility function checks whether m
is a numeric matrix
of the correct dimensions, and checks for NA
values.
If matchto="nrow"
(the default) then
the number of rows of m
must be equal to npoints
.
If matchto="ncol"
then the number of columns of m
must be equal to npoints
. If squarematrix=TRUE
(the
default) then the numbers of rows and columns must be equal.
If naok = FALSE
(the default) then the entries of m
must not include NA
.
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.
# NOT RUN {
z <- matrix(1:16, 4, 4)
check.nmatrix(z, 4)
# }
Run the code above in your browser using DataCamp Workspace