Hi! I am trying to reorder a dendrogram via reorder.dendrogram. However, I observed some problems with this, and I will illustrate them with an example.
Take the following clustering problem: datamatrix <- matrix(c(2,2,2.5,2,1.5,2,2,1.5,2,2.5, 6,2,6.5,2,5.5,2,6,1.5,6,2.5, 4,4,4.5,4,3.5,4,4,3.5,4,4.5), ncol=2, byrow=TRUE) distmatrix <- dist(datamatrix, method="manhattan") hc <- hclust(distmatrix, method="single") dendro <- as.dendrogram(hc) The datamatrix contains three equidistant (for manhattan distance) clusters, each of which contains 5 points. Now, I want to impose an order: weights <- c(2.0, 2.0, 2.0, 2.0, 2.0, 6.0, 6.0, 6.0, 6.0, 6.0, 4.0, 4.0, 4.0, 4.0, 4.0) ddd <- reorder(dendro, weights, agglo.FUN=mean) but if you compare the order of ddd with dendro, you see no change: unlist(ddd) [1] 15 14 13 11 12 5 4 3 1 2 10 9 8 6 7 unlist(dendro) [1] 15 14 13 11 12 5 4 3 1 2 10 9 8 6 7 I would have expected something like: 5 4 3 1 2 15 14 13 11 12 10 9 8 6 7 or something of the sort. (I still do not know, if the order should be ascending or descending, but in the obtained result, it is neither nor). I do not see, where my mistake is ... Thanks for your advice! Thomas. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.