Question: I have two dendrograms which I wish to compare to each other in order to find out how "similar" they are. But I don't know of any method to do so (let alone a code to implement it, say, in R).

Any leads ?

**UPDATE** (2014-09-13):

Since asking this question, I have written an R package called [dendextend](http://cran.r-project.org/web/packages/dendextend/), for the visualization, manipulation and **comparison** of dendrogram. This package is on [CRAN](http://cran.r-project.org/web/packages/dendextend/) and comes with a [detailed vignette](http://cran.r-project.org/web/packages/dendextend/vignettes/introduction.html). It includes functions such as `cor_cophenetic`, `cor_bakers_gamma` and `Bk` / `Bk_plot`. As well as a `tanglegram` function for visually comparing two trees.

Answer: 
have a look at [this page](http://r.789695.n4.nabble.com/How-to-Compare-Two-dendrograms-Hierarchical-Clusterings-td1563467.html): 

I also have similar question asked [here](https://stackoverflow.com/questions/25799921/which-r-function-to-calculate-cophenetic-correlation)

It seems we can use cophenetic correlation to measure the similarity between two dendrograms. But there seems no function for this purpose in R currently.

**EDIT at 2014,9,18:**
 The `cophenetic` function in `stats` package is capable to calculating the cophenetic dissimilarity matrix. and the correlation can be calculated using `cor` function. as @Tal has pointed the `as.dendrogram` function returned the tree with different order, which will cause wrong results if we calculate the correlation based on the dendrogram results. As showed in the example of function `cor_cophenetic` function in `dendextend` package:

```
set.seed(23235)
ss <- sample(1:150, 10 )
hc1 <- iris[ss,-5] %>% dist %>% hclust("com")
hc2 <- iris[ss,-5] %>% dist %>% hclust("single")
dend1 <- as.dendrogram(hc1)
dend2 <- as.dendrogram(hc2)
# cutree(dend1)
cophenetic(hc1)
cophenetic(hc2)
# notice how the dist matrix for the dendrograms have different orders:
cophenetic(dend1)
cophenetic(dend2)
cor(cophenetic(hc1), cophenetic(hc2)) # 0.874
cor(cophenetic(dend1), cophenetic(dend2)) # 0.16
# the difference is becasue the order of the distance table in the case of
# stats:::cophenetic.dendrogram will change between dendrograms!

```
If you have access to the underlying distance matrix that generated each dendrogram (you probably do if you generated the dendorograms in R), couldn't you just use correlation between the corresponding values of the two matrices? I know this doesn't address the letter of what you asked, but it's a good solution to the spirit of what you asked.