This function applies the 'metricDistance' function to calculate distances from a given reference point to each row in a matrix of candidate nearest neighbors. It is particularly useful in the situation between matrix and a vector
Usage
distanceVector(point, candidateNNs, n)
Arguments
- point
Numeric vector, the reference point from which distances are calculated.
- candidateNNs
Matrix, rows represent candidate points to which distance from the reference point is calculated.
- n
Integer, the order of the Minkowski distance to use.
Value
Numeric vector, distances from the reference point to each of the candidate points.
Examples
point <- c(1, 2, 3)
candidateNNs <- matrix(c(4, 5, 6, 7, 8, 9), nrow = 2, byrow = TRUE)
n <- 2
distances <- distanceVector(point, candidateNNs, n)
print(distances)
#> [1] 5.196152 10.392305