Karl Forner
2011-Jan-28 11:54 UTC
[Rd] Possible bug in cut.dendrogram when there are only 2 leaves in the tree ?
Hello, I noticed a behavior ot the cut() function that does not seem right. In a dendrogram with only 2 leaves in one cluster, if you cut() at a height above this cluster, you end up with 2 cut clusters, one for each leaf, instead of one. But it seems to work fine for dendrograms with more than 2 objects. For instance: library(stats) m <- matrix(c(0,0.1,0.1,0),nrow=2, ncol=2) dd <- as.dendrogram(hclust(as.dist(m))) #plot(dd) print(cut(dd, 0.2)) # 2 clusters in $lower m2 <- matrix(c(0,0.1,0.5,0.1,0,0.5,0.5,0.5,0),nrow=3, ncol=3) dd <- as.dendrogram(hclust(as.dist(m2))) print(cut(dd, 0.2)) # here 2 clusters in $lower, as expected So the question is: is it expected behavior that the whole tree is not reported in the $lower if it is itself under the threshold ? Thank you, Karl FORNER [[alternative HTML version deleted]]