Skip to contents

Check if an argument is a matrix with contiguity matrix properties.

Usage

checkContiguityMatrix(
  x,
  isComplete = TRUE,
  any.missing = FALSE,
  all.missing = FALSE,
  nrows = NULL,
  ncols = nrows
)

assertContiguityMatrix(
  x,
  isComplete = TRUE,
  any.missing = FALSE,
  all.missing = FALSE,
  nrows = NULL,
  ncols = nrows,
  .var.name = checkmate::vname(x),
  add = NULL
)

testContiguityMatrix(
  x,
  isComplete = TRUE,
  any.missing = FALSE,
  all.missing = FALSE,
  nrows = NULL,
  ncols = nrows
)

Arguments

x

Matrix to be tested

isComplete

A flag set to TRUE if x is supposed to be a distance matrix of a complete set, i.e. must be symmetric with 0 at the diagonal (can be NA if any.missing = TRUE).

any.missing

Are missing values allowed? Default is FALSE.

all.missing

Are matrices with only missing values allowed? Default is FALSE.

nrows, ncols

exact number of rows and columns. If NULL check is ignored. If isComplete is TRUE then nrows must be equals to ncols

.var.name

Name of the checked object to print in assertions. Defaults to the heuristic implemented in checkmate::vname().

add

Collection to store assertion messages. See checkmate::AssertCollection.

Value

Please see checkmate::checkMatrix() help page (for instance) for further details about the difference between check_, test_ and assert_ functions results.

Details

Extension of the checkmate package.

See also

Examples

M <- matrix(c(FALSE,  TRUE, FALSE,
              TRUE, FALSE,  TRUE,
              FALSE,  TRUE, FALSE), nrow = 3L)
checkContiguityMatrix(M, isComplete = TRUE)
#> [1] TRUE