[R] Help on reorder the dendrogram
Chih-Hsin
hchihh at gmail.com
Sun Feb 16 06:54:37 CET 2014
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.
More information about the R-help
mailing list