dist_make {usedist} | R Documentation |
Make a distance matrix using a custom distance function
Description
Make a distance matrix using a custom distance function
Usage
dist_make(x, distance_fcn, ...)
Arguments
x |
A matrix of observations, one per row |
distance_fcn |
A function used to compute the distance between two
rows of the data matrix. The two rows will be passed as the first and
second arguments to |
... |
Additional arguments passed to |
Details
We do not set the call
or method
attributes of the
dist
object.
Value
A dist
object containing the distances between rows of the
data matrix.
Examples
x <- matrix(sin(1:30), nrow=5)
rownames(x) <- LETTERS[1:5]
manhattan_distance <- function (v1, v2) sum(abs(v1 - v2))
dist_make(x, manhattan_distance)
[Package usedist version 0.4.0 Index]