Hi all, I would like to reorder the leaves of a dendrogram. I attached the tree in the attachment. The code I apply is
reorder.tree = function( Dend, # the dendrogram you want to order order.n){ # the order of leaves from left to right new.order = rbind(order.n, 1:length(order.n)) wts = new.order[2, order(new.order[1,])] new.Dend = reorder(Dend, wts, min) return(new.Dend) } the order I want is order.n = c(5,1,8,2,4,6,7,12,3,9,10,11) But when I apply the reorder function, it gives me > Dend = as.dendrogram(Tree) > new.Dend = reorder.tree(Dend,order.n) > order.dendrogram(new.Dend) [1] 8 5 1 2 4 6 7 12 3 9 10 11 Thanks for answering the question. Best, CH.
______________________________________________ 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.