Skip to contents

Subset operator for the distance matrix stored as an object of class stats::dist.

Usage

# S3 method for dist
[(x, i, j, drop = TRUE, ...)

Arguments

x

An object of class stats::dist.

i

An integer vector of row indices. Values must be either all positive in which case they indicate the rows to select, or all negative in which case they indicate the rows to omit.

j

An integer vector of column indices. Values must be either all positive in which case they indicate the columns to select, or all negative in which case they indicate the columns to omit.

drop

A logical value indicating whether the result should be coerced to a vector or matrix if possible.

...

Additional arguments passed to [.dist.

Value

A numeric matrix storing the pairwise distances between the requested observations.

Examples

D <- stats::dist(iris[, 1:4])
D[2:3, 7:12]
#>           7         8         9        10        11        12
#> 2 0.5099020 0.4242641 0.5099020 0.1732051 0.8660254 0.4582576
#> 3 0.2645751 0.4123106 0.4358899 0.3162278 0.8831761 0.3741657