I have 583 observations within my dataset, out of which I need to use 100 to make a Dendrogram. But I am getting the following error in the plot() function step.
how to troubleshoot/solve this?
##For 100 Observations
set.seed(44)
idx_100 <- sample(1:nrow(ilpd_df), 100)
distance_matrix_100 <- dist(as.matrix(ilpd_df[idx_100,-c(1,2,10,11)]),
method = "euclidean") #Creates Hierarchical Clustering Solution
hc_100 <- hclust(distance_matrix_100)
plot(hc_100, hang = -1, labels=ilpd_df$Class) #CANT PLOT DUE TO INVALID INPUT ERROR
Could you put some minimal data that can be used to replicate the problem?
I find no issue (R 3.6.1) with plot.hclust()
.
The following simple code
hc <- hclust(dist(USArrests)^2, "cen")
class(hc) # [1] "hclust"
plot(hc, hang = -1, main = "Sample Tree", cex = .5)
Produces