# How to convert a dendrogram back into a distance matrix?

Example code:

our_dist <- dist(USArrests[1:4,])
dend <- as.dendrogram(hclust(our_dist , "ave"))
plot(dend )


I would now wish to have a "dend2dist" function which will turn dend back to our_dist.

Of course, it is not possible to do in full (AFAIK), since the process of turning the dist into the dendrogram aggregated a lot of the data which can not be retrieved. But still, I would like for our "best guess" (assuming which aggregation method was used for the dendrogram), as to what is some distance which would be able to reproduce the original dendrogram.

And of course, tips on how to best implement such a function in R would also be nice.

Any suggestions will be most welcomed, thanks.

• I'm afraid that task is unfeasible. As you noticed, dendrogram summarizes much information elements of which cannon be retrieved back from it. – ttnphns Feb 24 '13 at 6:46
• Hello dear ttnphns - I agree it is not possible to do this in full. However, it can be partially obtained, and I wonder if anyone has ever dealt with that... – Tal Galili Feb 24 '13 at 7:05

d1 <- dist(USArrests)