[R] distance in kmeans algorithm?
timo.becker at oeaw.ac.at
Mon Jul 10 14:51:00 CEST 2006
>Is it possible to choose the distance in the kmeans algorithm?
>I have m vectors of n components and I want to cluster them using kmeans
>algorithm but I want to use the Mahalanobis distance or another distance.
>How can I do it in R?
>If I use kmeans, I have no option to choose the distance.
>Thanks in advance,
You can use Kmeans from the amap package with several distance measures.
# example for L1 and L2:
x <- matrix(c(0,0,0,1.5,1,-1), ncol=2, byrow=TRUE)
Kmeans(x, x[2:3,], method="manhattan")
Kmeans(x, x[2:3,], method="euclidean")
Austrian Academy of Sciences
Acoustics Research Institute
More information about the R-help