spatstat.utils (version 1.17-0)

check.nmatrix: Check for Numeric Matrix with Correct Dimensions

Description

This is a programmer's utility function to check whether the argument is a numeric vector of the correct length.

Usage

check.nmatrix(m, npoints = NULL, fatal = TRUE, things = "data points",
              naok = FALSE, squarematrix = TRUE, matchto = "nrow", warn = FALSE)

Arguments

m

The argument to be checked.

npoints

The required number of rows and/or columns for the matrix m.

fatal

Logical value indicating whether to stop with an error message if m does not satisfy all requirements.

things

Character string describing what the rows/columns of m should correspond to.

naok

Logical value indicating whether NA values are permitted.

squarematrix

Logical value indicating whether m must be a square matrix.

matchto

Character string (either "nrow" or "ncol") indicating whether it is the rows or the columns of m which must correspond to npoints.

warn

Logical value indicating whether to issue a warning if v does not satisfy all requirements.

Value

A logical value indicating whether all the requirements were satisfied.

Details

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.

See Also

check.nvector

Examples

Run this code
# NOT RUN {
  z <- matrix(1:16, 4, 4)
  check.nmatrix(z, 4)
# }

Run the code above in your browser using DataCamp Workspace