dist_subset: Extract parts of a 'dist' object.

Description Usage Arguments Value Examples

Description

Extract a subset of values from a distance matrix. This function also works to re-arrange the rows of a distance matrix, if they are provided in the desired order.

Usage

1
dist_subset(d, idx)

Arguments

d

A distance matrix object of class dist.

idx

Indices specifying the subset of distances to extract.

Value

A distance matrix.

Examples

1
2
3
4
m4 <- matrix(1:16, nrow=4, dimnames=list(LETTERS[1:4]))
dm4 <- dist(m4)
dist_subset(dm4, c("A", "B", "C"))
dist_subset(dm4, c("D", "C", "B", "A"))

Example output

  A B
B 2  
C 4 2
  D C B
C 2    
B 4 2  
A 6 4 2

usedist documentation built on March 2, 2020, 1:07 a.m.