I have a matrix similarity matrix as follows. Now i want to do hierarchical clustering by keeping some distance cutoff like if it is 2. the hierarchical clustering should be take the distance value 2 and cluster the sample A,B,C and D accordingly.
I tried doing in R. but couldn't set the threshold value. Could anyone please help me the solve the problem in R.
A B C D
A|0|1|2|3
B|1|0|3|5
C|2|3|0|1
D|3|5|1|0
Thanks in advance,
yes ... u understood it correctly.. i.e. cuts the tree to define clusters based on a given height ... thanks i ll try the commands n let u know
Thanks seidel it works... but getting one error when i set the cutoff of 0.5. the error is "Error in rect.hclust(hr, h = 0.5) : k must be between 2 and 377"
What is your basis for choosing 0.5? Given that error, if you look at your dendrogram, it's likely that none of the distances are less than 0.5. You can see them directly by examining hr$height. You might try range(hr$height). You can't choose to cut lower than the smallest distance. What is your range of distances?
thanks @seidel... but the matrix does contain some values which is within the range of 0.5.