Have you tried as.dist(distmat)?
Christian
On Wed, 19 Oct 2005, Tim Smith wrote:
> Hi all,
>
> I wanted to run the hclust (or any other clustering algorithm) on a
distance matrix. I have formed the distance matrix as:
>
> distmat:
>
> a b c d e
> a 0.00 0.96 1.60 1.60 1.68
> b 0.96 0.00 0.96 1.80 2.64
> c 1.60 0.96 0.00 0.84 1.80
> d 1.60 1.80 0.84 0.00 0.96
> e 1.68 2.64 1.80 0.96 0.00
>
> Now, I would like to run a clustering algorithm on it. I tried:
>
> newclust = hclust(distmat)
>
> and got the following error:
>
> Error in if (n < 2) stop("Must have n >= 2 objects to
cluster") :
> argument is of length zero
>
> I understand that the documentation says that the matrix ' d: a
dissimilarity structure as produced by 'dist''. Does that mean that
I need to convert it into a lower triangle matrix? I also tried:
>
> newclust = hclust(vech(distmat))
>
> but this gave a similar error. Where am I going wrong?
>
>
> Also, will hclust be able to handle 'NA' in the dissimilarity
matrix?
>
> many thanks,
>
>
> Tim
>
>
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
>
*** --- ***
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