I cannot seem to find a thread relating to my issue (in simple terms at least).
I have a community matrix of species (columns) by sample sites (rows). I firstly performed a Bray-Curtis transformation to get a similarity/dissimilarity matrix (vegdist
) and secondly, applied hclust
function to the matrix.
Section of script I used:
library(vegan)
community_matrix <- read.csv(choose.files(),sep=",",row.names=1)
d = (1 - vegdist(community_matrix, method="bray")) * 100
h = hclust(d, method = "ward.D2")
plot(h, main = "", sub = "", xlab="", ylab = "Bray-Curtis simmilarity", axes = FALSE, hang = -1)
Everything works perfect however, the above resulted in a dendrogram tree with 127 branches (one for each sample site). I want to rather group the 127 sample sites by 5 HABITATS these sites belong to. Then the dendrogram's branches would show a more understanding, 5-branched (habitats) dendrogram instead of sample sites. Thus, clustering must be performed on the habitats and weighted by sample sites.
I performed this analysis before in PC-ORD but this time it must be done in unforgiving R.