How to extract the "perfect" individual of dendrogram clusters built with hclust

Hello everyone,

My question is quite simple but I struggle to get a simple answer. I created 30 clusters of trees by height and width in a field using hclust. Then what I would like is to select the individuals that are the closest to the centroid of each cluster to extract them as they will be the ones I use for my samples. I already managed to extract the labels of individuals per Cluster using get_subdendrograms and transfer them in a data frame using a loop, but then I loose the information of which individual is the closest to the centroid of clusters.

Anyone that could help ?

here is my script :

dend = donneereduit2 %>%
dist() %>%
hclust() %>%
as.dendrogram() %>%
color_branches(k = 30)

dend_list <- get_subdendrograms(dend, 30)
laliste = lapply(dend_list, labels)

df <- data.frame(
Nom_arbre = character(),
Num_cluster = integer(),
stringsAsFactors = FALSE
Nom_arbre = c()
clusters = c()

for (i in (1:30)){
for (i in (1:length(laliste))){
for (k in (1:lengths(laliste[i]))){
row_j <- c(laliste[[i]][k], i)
df[nrow(df)+1,] <- row_j

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.