[R-sig-eco] Reordering dendogram

syrovat syrovat at sci.muni.cz
Wed Oct 11 10:22:04 CEST 2017


(Sorry for double-posting, the original message does not seem to appear 
in the forum.)

"Everything" seems to be possible with the dendextend package.
Check its extensive vignette at CRAN.
Vit


Dne 2017-10-10 14:54, Tania Bird napsal:
> I am trying to control the order and colour of a dendrogram. Obviously
> the point of the dendorgram is to order by similarity, but within
> branches I'd like to set an order that make sense
> (alphabetical-numeric).
> 
> library(vegan)
> library(stats)
> 
> x <-data.frame(data = c(1:10))
> y = data.frame(type = c("A","B","C","A","C","D","A","B","C","B"),
> site_name = c("A1","B1","C1","A2","C2","D1","A3","B2","C3","B3"))
> row.names(x) = y$site_name
> dis = vegdist(x)
> hc <- hclust(dis)
> dd <- as.dendrogram(hc)
> plot(dd)
> 
> My data labels are text but they do have a set order listed in a 
> variable
> 
> site_order = c("A1","A2","A3","B1","B2","B3","C1","C2","C3","D1")
> 
> 1) I'd like to find a solution that sorts the dendogram according to
> site_order within branches.
> 
> e.g. A1,B1,        A2, C1,   C2,D2,             A3,B2,     B3,C3
> 
> I also want to colour and shape the labels using site_type e.g (A= red
> circle , B= blue square , C= green triangle, D = yellow cross)
> 
> Is this possible?
> 
> 
> Thanks
> 
> Tania Bird MSc
> "There is a sufficiency in the world for man's need but not for man's
> greed" ~ Mahatma Gandhi
> 
> https://www.linkedin.com/in/taniabird
> https://taniabird.webs.com
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



More information about the R-sig-ecology mailing list