R function from {stats} package - hierarchical cluster analysis on a set of dissimilarities and methods for analyzing it.
Questions tagged [hclust]
176 questions
1
vote
0 answers
how to find & label centroids of clusters created by hclust() in R?
I read the thread there but in this thread, the answer is saying using the column means for the cluster i (so if I have 3 clusters in total, i = 1,2,3; and if I have 2 clusters overall, i = 1,2).
I will copy and paste their answers here:
clusters =…

alwaysaskingquestions
- 1,595
- 5
- 22
- 49
1
vote
1 answer
R - Isolate clusters with specific characteristics in hclust
I've used hclust to generate a cluster dendrogram of some data, but I need to isolate all the paired clusters, i.e. all the clusters that comprise just 2 pieces of data (the first ones to be clustered together), even if they might be clustered with…

Rquestion550
- 13
- 2
1
vote
1 answer
match and add the cluster number to the original data
I am using the regular method to do a Hierarchical Clustering project.
mydata.dtm <- TermDocumentMatrix(mydata.corpus)
mydata.dtm2 <- removeSparseTerms(mydata.dtm, sparse=0.98)
mydata.df <- as.data.frame(inspect(mydata.dtm2))
mydata.df.scale <-…

janicebaratheon
- 976
- 1
- 10
- 21
1
vote
0 answers
How to use hclust() in R when dataset has NA values
How can I use hclust() in R when the dataset I am using has NA values? This is the function I have set up:
data2 = apply(data,2, as.numeric)
data2.hclust = hclust(data2, method='median')
When I attempt this I receive this error message:
Error in if…

bubbalouie
- 643
- 3
- 10
- 18
1
vote
2 answers
how to transform the following similarity matrix to distance matrix for performing hclust?
I am trying to cluster nodes (C1, C2, C3...) of a graph using hclust and my similarity metric is number of links between nodes.
I have data like
c = matrix( c(0,1,3,1,0,5,3,5,0), nrow=3, ncol=3)
Basically this is a similarity matrix
C1 C2 …

rk567
- 289
- 1
- 4
- 16
1
vote
1 answer
Subsets of a dataset as separate dendrograms, but in the same plot
I know I can plot a dendrogram as follows
library(cluster)
d <- mtcars
d[,8:11] <- lapply(d[,8:11], as.factor)
gdist <- daisy(d, metric = c("gower"), stand = FALSE)
dendro <- hclust(gdist, method = "average")
plot(as.dendrogram(dendro))
However I…

Crops
- 5,024
- 5
- 38
- 65
1
vote
1 answer
Get names of specific members of clusters of heatmap() function R
Once you generate a heat map using 'heatmap()' function in R, is there a way to focus in and extract the members of a specific cluster?
I have a heat map of 4500 x 420 members and it would be useful.
Thanks.

tomathon
- 834
- 17
- 32
1
vote
1 answer
How to print the order of hierarchical clustering in R?
Using the following matrix of distances between 6 Italian cities:
0 662 877 255 412 996
662 0 295 468 268 400
877 295 0 754 564 138
255 468 754 0 219 869
412 268 564 219 0 669
996 400 138 869 669 0
Will R output the order of which it…

user2679447
- 195
- 1
- 3
- 8
1
vote
2 answers
Adding labels to a dendrogram in ggplot using ggdendro in r
How can I add labels to a ggdendro plot? I realise from reading ?dendro_data that I am suppose to use the the call 'labels' but can't find an example of actual implementation. Could anybody please demonstrate how to add leaf labels to the example…

Elizabeth
- 6,391
- 17
- 62
- 90
1
vote
2 answers
Extracting the tree structure in text from hclust in R
In the scope of a demand forecasting project, I would like to determine the best way to group time series that have similarity with each other so I can apply a Top Down forecasting algorithm. At the moment, my key question is to determine what are…

Jochem
- 3,295
- 4
- 30
- 55
0
votes
0 answers
How do I save SVG plots from Databricks in R?
I have the following R code which I can run in R Studio to generate a CDH dendogram plot and save it locally as a SVG.
c1 <- hclust(as.dist(subs_matrix), method = "ward.D2") #ward.D2
#scale the branches of the tree, only changes the aesthetics the…

Sam Eley
- 19
- 2
0
votes
2 answers
How to get the new hclust object after using cutree function in R
How do I get the new hclust object after using cutree function? I know the standard output from cutree is a numerical vector that tells you the clusters each leaf node belongs. However, how can we get the aggregated tree structure after cutting at a…
0
votes
3 answers
How to replace dendrogram labels using only base R and/or ggplot2 packages?
I want to perform dendrogram visualization using hierarchical grouping with Minkowski method on my dataset from eurostat library. I want to make values shown in this dendrogram:
to display country names like in this one
I can only use base R…

Radeq2137
- 5
- 3
0
votes
1 answer
Bootstrapped hclust with real data
I have a dataset with multiple observations for each category:
country PC1 PC2 PC3 PC4 PC5
BD 0.0960408090569664 0.373740208940467 -0.369920989335273 -1.02993010449105 -0.481901935725247
BD -0.538617581045194 0.537010643603669 …

Shakir
- 343
- 5
- 23
0
votes
0 answers
Collapsing an internal node in a dendrogram in R
I have a dendrogram produced by hclust in R. I want to collapse one internal node and
get the resulting new hclust object (for plotting etc). Note that I'm not doing a horizontal cut
but just collapsing one node. Thanks!
I've looked through the…