[R] i need help in cluster analyse

Simon Blomberg Simon.Blomberg at anu.edu.au
Fri Jul 18 02:03:05 CEST 2003


Rodrigo,

You need to think about what type of clustering algorithm you intend to use. There are many choices. A simple example to get you started is:

dist <- read.table("matrix.txt", header=TRUE) # read in your matrix from a text file
dend <- hclust(as.dist(dist), method="average") # do clustering, using UPGMA method
plot(dend) #plot your dendrogram

See ?hclust for more methods. There are also other packages on CRAN that do cluster analysis.

Simon.

Simon Blomberg, PhD
Depression & Anxiety Consumer Research Unit
Centre for Mental Health Research
Australian National University
http://www.anu.edu.au/cmhr/
Simon.Blomberg at anu.edu.au  +61 (2) 6125 3379


> -----Original Message-----
> From: Rodrigo [mailto:rgazaffi at uol.com.br]
> Sent: Friday, 18 July 2003 9:00 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] i need help in cluster analyse
> 
> 
> Hello,
> My name is Rodrigo, I am using R program and I have a trouble.
>  
> I am trying to do a dendrogram with genetics information.
> Let me explain...
> The Similarity Matrix was already did, and with this matrix I 
> want to construct a dendrogram.
> So, the distance is done. I need to transform this matrix 
> (that I have) in a dendrogram,
>  
> I woud be very grateful if someone could help me.
> PS: I am sending a example together, for the matrix I have 
> and want to transform in a dendrogram.
> 
> best wish to all.
> Thank you for the attention.
> 
> ##############################################################
> ##################################
>      1         2         3         4         5         6      
>    7         8         9         10         11         12     
>     13     14
> 01 1.0000 0.4500 0.2174 0.3636 0.3810 0.2632 0.5000 0.4167 
> 0.2500 0.4286 0.3182 0.3333 0.3684 0.2778 
> 02 0.4500 1.0000 0.3750 0.4583 0.4167 0.4737 0.4074 0.3929 
> 0.3600 0.4000 0.2593 0.3846 0.4762 0.3500 
> 03 0.2174 0.3750 1.0000 0.4167 0.4348 0.3684 0.3214 0.4074 
> 0.3333 0.4167 0.3200 0.4783 0.3636 0.3889 
> 04 0.3636 0.4583 0.4167 1.0000 0.5217 0.3478 0.4444 0.5385 
> 0.5417 0.5000 0.4583 0.5600 0.5238 0.4286 
> 05 0.3810 0.4167 0.4348 0.5217 1.0000 0.4000 0.5833 0.5000 
> 0.5455 0.5217 0.4167 0.5652 0.3478 0.2273 
> 06 0.2632 0.4737 0.3684 0.3478 0.4000 1.0000 0.2800 0.2593 
> 0.3913 0.3182 0.3043 0.3077 0.3000 0.4706 
> 07 0.5000 0.4074 0.3214 0.4444 0.5833 0.2800 1.0000 0.5926 
> 0.5200 0.5600 0.4615 0.4815 0.3462 0.2917 
> 08 0.4167 0.3929 0.4074 0.5385 0.5000 0.2593 0.5926 1.0000 
> 0.4815 0.4815 0.4444 0.5556 0.3846 0.3200 
> 09 0.2500 0.3600 0.3333 0.5417 0.5455 0.3913 0.5200 0.4815 
> 1.0000 0.5909 0.5652 0.4815 0.4545 0.3478 
> 10 0.4286 0.4000 0.4167 0.5000 0.5217 0.3182 0.5600 0.4815 
> 0.5909 1.0000 0.4583 0.6087 0.4545 0.2727 
> 11 0.3182 0.2593 0.3200 0.4583 0.4167 0.3043 0.4615 0.4444 
> 0.5652 0.4583 1.0000 0.5200 0.3478 0.2609 
> 12 0.3333 0.3846 0.4783 0.5600 0.5652 0.3077 0.4815 0.5556 
> 0.4815 0.6087 0.5200 1.0000 0.4167 0.2222 
> 13 0.3684 0.4762 0.3636 0.5238 0.3478 0.3000 0.3462 0.3846 
> 0.4545 0.4545 0.3478 0.4167 1.0000 0.3158 
> 14 0.2778 0.3500 0.3889 0.4286 0.2273 0.4706 0.2917 0.3200 
> 0.3478 0.2727 0.2609 0.2222 0.3158 1.0000 
> 
> 
> This matrix have 14 individuals and the analyse of similarity 
> (the range of statistic is 0 to 1).
> I want to use it in that way to the cluster analyse.
>  
> 
> 
> 
> 
> ---
> 
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>




More information about the R-help mailing list