Comparing different variables, I got a matrix with lots of missing values.
How do I have to transform the matrix below for hierarchical clustering?
What I have already tried:
x = read.csv("xyz.csv", sep = ";", row.names = 1, header = TRUE) x[is.na(x)] = FALSE # transform to correlation matrix x = cor(t(x), method = "pearson") # elbow method fviz_nbclust(x, FUN = hcut, method = "wss") # cluster with ward method hc = hclust(dist(x), method = "ward.D2") # show clusters rect.hclust(hc,k=3, border="red") plot(hc)
This clustering result looks wrong:
Right keyword for further search "dissimilarity matrix". Now i tried to transform the matrix into a distance matrix.
x= as.dist(x, diag = TRUE) hc = hclust(dist(x), method = "ward.D2") plot(hc)
that´s not a solution yet