From this dendrogram, I would like to extract the height for each leaf. In this case example, I would like to get back a list like this :
list("A" = 2.07, "B" = 5.09, "C" = 3.12, "D" = 2.07, "E" = 3.12)
Here's the code for this example:
m <- matrix(rnorm(30), nrow = 5)
rownames(m) <- LETTERS[1:5]
d <- dist(m)
h <- hclust(d)
plot(h)
I can extract the height from the dendrogram easily with
h$height
And see the information I want with
str(as.dendrogram(h))
But I couldn't find a way to extract what I want. I also looked into the dendextend
package but I couldn't find what I want.
Do you know a function that already does this? I'm not very familiar with S3 objects...