The kmeans function doesn't accept a distance object or distance matrix as
input (which you can of course generate from your own definition), but pam
in package cluster does. (Note that the term "k-means" refers to
cluster
mean vectors, which can only computed from a cases*variables data matrix,
not from distances alone.)
There are also several other clustering methods that work with distance
matrices as input, see for example hclust, agnes from package cluster or
dbscan from package fpc, but if you want something that is
conceptually close to k-means, you should probably go for pam.
Best regards,
Christian
On Tue, 7 Sep 2010, Karen Sargsyan wrote:
> Is it possible to implement my own distance and mean for k-means clustering
> for any clustering package in R?
> Just looking for simple way, without creating a new package.
>
> karsar
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chrish at stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche