computeIdxFromDistIdx computes the indices of two points whose distance appears at given position in a distance matrix (as computed by dist).

computeIdxFromDistIdx(n, i)

Arguments

n

number of points

i

index into the distance matrix

Value

a vector of two indices of points whose distance appears at given position in a distance matrix.

See also

Examples

x <- 1:10 d <- dist(x) # entries holding distances between point 3 and 7 i<-computeDistIdx(length(x), 3, 7) print(i)
#> [1] 21
# restore indices of the points: ii<-computeIdxFromDistIdx(length(x), i)
#> [1] 6.946222 #> [1] 3
print(ii)
#> [1] 3 7