Re: [R] creating dendrogram from cluster hierarchy

From: Martin Maechler <>
Date: Tue 28 Feb 2006 - 21:19:47 EST

>>>>> "Timo" == Timo Becker <>
>>>>> on Tue, 28 Feb 2006 11:01:26 +0100 writes:

    Timo> Dear R users, I have created data for hierarchical
    Timo> agglomerative cluster analysis which consist of the
    Timo> merging pairs and the agglomeration heights, e.g.
    Timo> something like

    Timo> my.merge <- matrix(c(-1,-2,-3,1), ncol=2, byrow=TRUE)     Timo> my.height <- c(0.5, 1)

    Timo> I'd like to plot a corresponding dendrogram but I
    Timo> don't know how to convert my data to achieve this.  Is
    Timo> it possible to create a dendrogram object from a
    Timo> cluster hierarchy?

Yes, it is possible. R does it already with the as.dendrogram() method for objects of class "hclust".

But I assume you'd also like to know *how* you can do it... ;-)

I'd strongly recommend to take the example of hclust() and have your function return an object ``like'' the one hclust() returns. Then, as.dendrogram( <your object> ) will work.

You have to decide for yourself if your function should return an object of class "hclust" (which is partly described by ?hclust ), and you use as.dendrogram[.hclust]() directly, or rather your function returns a class "hclustTimo" and you write your own as.dendrogram.hclustTimo() method.

I'd recommend looking at and using the R's source code, e.g., from and

Martin Maechler, ETH Zurich mailing list PLEASE do read the posting guide! Received on Tue Feb 28 21:30:21 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:47 EST