Re: [R] distance in kmeans algorithm?

From: Timo Becker <timo.becker_at_oeaw.ac.at>
Date: Mon 10 Jul 2006 - 22:51:00 EST

>
>Hello.
>
>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,
>
>Arnau.
>
>
>
>
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) require(amap)
Kmeans(x, x[2:3,], method="manhattan")
Kmeans(x, x[2:3,], method="euclidean")

Cheers,
Timo

-- 
Timo Becker
Phonetics
Austrian Academy of Sciences
Acoustics Research Institute

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Jul 10 23:01:23 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 11 Jul 2006 - 00:17:19 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.