> >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 ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
