Skip to contents

Check if an argument is a distance matrix

Usage

checkDistanceMatrix(
  x,
  isComplete = TRUE,
  any.missing = FALSE,
  all.missing = FALSE
)

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

testDistanceMatrix(
  x,
  isComplete = TRUE,
  any.missing = FALSE,
  all.missing = FALSE
)

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.

.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(0.0, 1.0, 2.3,
              1.0, 0.0, 3.2,
              2.3, 3.2, 0.0), nrow = 3L)

checkDistanceMatrix(M, isComplete = TRUE)
#> [1] TRUE