Questions tagged [hclust]

R function from {stats} package - hierarchical cluster analysis on a set of dissimilarities and methods for analyzing it.

176 questions
0
votes
0 answers

Cut dendrogram / cluster: Error in function 'cutree': tree incorrect (composante 'merge')

I have a dendrogram which I want to cut into less clusters because right know there are too many for interpretation. My dataframe looks like this: > head(alpha) locs 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 1 …
tubby
  • 11
  • 1
  • 4
0
votes
1 answer

Find Accuracy of an agglomeration method?

I have plotted a dendrogram using maximum agglomeration method. hc <- hclust(distance_matrix, method = "complete") plot(hc, hang = 0, labels=ilpd_df$Class) Q1) How can I find the accuracy of this agglomeration method? Q2) How should one comment on…
0
votes
0 answers

R, hclust : How to create a representative for each cluster?

I've got my clusterisation done, now, I want to use it to replace missing values. My idea is to compute a representative for each cluster then replace missing values according to that representative. The problem is... I don't really know how to do…
FBiggio
  • 35
  • 1
  • 5
0
votes
1 answer

Unexpected crash while clustering with RStudio on ec2 (AWS)

I am experiencing crashes with RStudio on the ec2 while clustering with currently 32 cores using the package doSNOW. The problem keeps happening and the logs in RStudio and the awslogs show following problems: The previous R session was abnormally…
agata
  • 61
  • 6
0
votes
1 answer

Compute distance between two nodes in a hclust dendrogram

Is there a way to compute the distance of two nodes, defined as the height of their lowest common ancestor, on a hclust dendrogram? A demo example can be referred here: Annotate the distance on nodes of a dendrograms
yliueagle
  • 1,191
  • 1
  • 7
  • 22
0
votes
1 answer

How to add labels to original data given clustering result using hclust

Just say I have some unlabeled data which I know should be clustered into six catergories, like for example this dataset: library(tidyverse) ts <- read_table(url("http://kdd.ics.uci.edu/databases/synthetic_control/synthetic_control.data"),…
pd441
  • 2,644
  • 9
  • 30
  • 41
0
votes
1 answer

cutree alternative to extract cluster with given number of objects

While stats::cutree() takes an hclust-object and cuts it into a given number of clusters, I'm looking for a function that takes a given amount of elements and attempts to set k accordingly. In other words: Return the first cluster with n…
Comfort Eagle
  • 2,112
  • 2
  • 22
  • 44
0
votes
1 answer

Adding table rows to labels of dendrogram

I'm essentially trying to change the labels of my dendrogram, to the corresponding row in the table. For instance, consider the USArrest data set. Right now the labels on the dendrogram are just the states name, "Alabama" and so on. But looking at…
Steven Cunden
  • 395
  • 1
  • 3
  • 9
0
votes
0 answers

How to do Hierarchical Clustering for Ordinal data-set in R?

I am trying to do Hierarchical clustering on a dataset where the columns are ordinal on the scale of 1 to 5. Based on Hierarchical clustering can be done using hclust() function. For doing analysis with ordinal data, we should use "Max" distance…
Arjun
  • 1
0
votes
1 answer

How to add cluster id in a seperate column of a dataframe?

I have produced a dendogram with hclust and cut it into two clusters. I know from the graph which row corresponds to which cluster. What I want to do is create a separate column in the dataframe that will contain element "class-1" if the row…
Amirul Islam
  • 407
  • 1
  • 6
  • 15
0
votes
1 answer

Prevent Background Image from Covering Plot

I am generating bubble charts from NBA shot data clusters. The final form of the data is: Where Group.1 is the index of the cluster, ad.SHOT_MADE_FLAG is the field goal percent for the cluster, coords.x1 and x2 are the mean x and y coordinates of…
Daniel
  • 33
  • 9
0
votes
2 answers

Rotate leaf labels in pvclust dendrogram plot

I'm using the pvclust package in R to perform bootstrapped hierarchical clustering. The output is then plotted as a hclust object with a few extra features (different default title, p-values at nodes). I've attached a link to one of the plots…
0
votes
2 answers

Function to color branches in dendrogram plot using base R

I would like to write R function for coloring branches in dendrogram based on the given dendrogram object, specified number of clusters and vector of colors. I want to use base R instead of dendextend. Using the exact code from this answer:…
ira
  • 2,542
  • 2
  • 22
  • 36
0
votes
1 answer

Reorder and colour dendogram based on labels

I am trying to control the order and colour of a dendrogram. Obviously the point of the dendorgram is to order by similarity, but within branches I'd like to set an order that make sense (alphabetical-numeric). library(vegan) library(stats) x…
Birdonawire
  • 199
  • 3
  • 10
0
votes
1 answer

hclust and ggplot r

I have a file with values as seen below gene_name s1 s2 s3 s4 s5 gene1 0.5004357 -0.9613324 1.4624021 -0.8051191 -0.1963863 gene2 1.1662839 -0.3210387 -0.3653730 -1.3095341 0.8296619 gene3 1.0511340 -0.7007560 -0.3025992 1.0511340…