Probably very simple,
I have a dendrogram:
set.seed(1)
my_mat <- matrix(rnorm(100),nrow=10,ncol=10)
my_dend <- as.dendrogram(hclust(dist(my_mat)))
and I want to use dendrapply to extract the height attribute from every node in my_dend, since it traverses the dendrogram in pre-order.
Trying dendrapply's example on my_dend:
dendrapply(my_dend, function(n) utils::str(attributes(n)))
It doesn't return a value but prints the information I need in pre-order. I thought that just getting the height attribute returned is as simple as:
dendrapply(my_dend, function(n) attr(n,"height"))
but obviously I'm wrong.
Any idea?