[R] Drawing dendrogram

Matthias Kohl Matthias.Kohl at stamats.de
Fri Jun 19 10:23:44 CEST 2009


maybe ?dendrapply is helpful - in particular see the example section.
There is also some code at http://www.stamats.de/Heatmap.R
(with commentary in German)

hth,
Matthias

Seyit Ali Kayis schrieb:
> Dear all, 
>
> I would like to draw a dendrogram and mark some parts/branches (by using "segments") including their labels. If I draw it without specifying the length of x axix, I am able to do that (as in My dendrogram 1 of the following codes). However, if I want to specify the x axix, I am not able to draw marking line (by using "segments") including labels (as in My dendrogram 2 of the following codes). Is there a way that I can include my labels into as well? Any help is deeply appreciated.
>
>  
>
> Kind Regards
>
>  
>
> Seyit Ali
>
>  
>
>  
>
> Codes:
>
>
> set.seed(201)
> x<-matrix(rnorm(100, 0, 1), ncol=20, byrow=TRUE)
> myclust<-  hclust(dist(cor(x), method='euclidian'), method="ave")
> mydend<-as.dendrogram(myclust)
>
> par(mfrow=c(1,2), mar=c(5,4,4,3), oma=c(1, 3, 1, 3))
>
> plot(mydend, xlim=c(4, -0.2), horiz = TRUE,  main="My Dendrogram 1")
>
> x0<- -0.35
> y0<- 0.5
> x1<- 1.8
> y1<- 0.5
> segments(x0, y0, x1, y1, col="red", lty=2)
>
> x0<- -0.35
> y0<- 4.4
> x1<- 1.8
> y1<- 4.4
> segments(x0, y0, x1, y1, col="red", lty=2)
>
> x0<- -0.35
> y0<- 0.5
> x1<- -0.35
> y1<- 4.4
> segments(x0, y0, x1, y1, col="red", lty=2)
>
> x0<- 1.8
> y0<- 0.5
> x1<- 1.8
> y1<- 4.4
> segments(x0, y0, x1, y1, col="red", lty=2)
>
> ################################################################################
>
> plot(mydend,  xlim=c(4, 0.5), horiz = TRUE, main="My Dendrogram 2", dLeaf=0.35)#, yaxt="n")
>
> x0<- 0.3
> y0<- 0.5
> x1<- 1.8
> y1<- 0.5
> segments(x0, y0, x1, y1, col="red", lty=2)
>
> x0<- 0.3
> y0<- 4.4
> x1<- 1.8
> y1<- 4.4
> segments(x0, y0, x1, y1, col="red", lty=2)
>
> x0<- 0.3
> y0<- 0.5
> x1<- 0.3
> y1<- 4.4
> segments(x0, y0, x1, y1, col="red", lty=2)
>
> x0<- 1.8
> y0<- 0.5
> x1<- 1.8
> y1<- 4.4
> segments(x0, y0, x1, y1, col="red", lty=2)
>
>
> ------------------------------------------------------------------------------------------------------------------ 
> Dr. Seyit Ali KAYIS
> Selcuk University
> Faculty of Agriculture
> Kampus, Konya, TURKEY
>
>             s_a_kayis at yahoo.com,    s_a_kayis at hotmail.com
> Tell: +90 332 223 2830  Mobile: +90 535 587 1139  Fax: +90 332 241 0108
>
>                    Greetings from Konya, TURKEY
>                 http://www.ziraat.selcuk.edu.tr/skayis/
> ---------------------------------------------------------------------------------------------------------------------- 
>
>
>
>
>
>
>
> _________________________________________________________________
> [[elided Hotmail spam]]
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>   

-- 
Dr. Matthias Kohl
www.stamats.de




More information about the R-help mailing list