Skip to contents

Materialises the wide form, with ids as both row and column names, sorted.

Usage

# S3 method for class 'pairwise_distances'
as.matrix(x, value = PAIRWISE_DISTANCES_VALUE_COL, ...)

Arguments

x

A pairwise_distances object.

value

Name of the column to fill cells with. Defaults to dissim.

...

Ignored.

Value

A numeric matrix, square, with sorted ids as dimnames.

Details

x must be square (see distances_assert_square, called here for you): every id present in both id1 and id2. A table filtered on one id column only is not; use distances_restrict to filter both.

Examples

d <- pairwise_distances(data.frame(
  id1 = c("A1", "A1", "A2", "A2"),
  id2 = c("A1", "A2", "A1", "A2"),
  dissim = c(0, 35, 35, 0)
))
as.matrix(d)
#>    A1 A2
#> A1  0 35
#> A2 35  0