我正在尝试绘制“中位数”聚类结果的树状图,但是发生的事情是这样:
Error in data.frame(xmin = unlist(xleft), ymin =
unlist(ybottom), xmax = unlist(xright), :
arguments imply differing number of rows: 5, 0
我对其他聚类方法“单”,“完全”,“平均”,“质心”等使用了相同的距离矩阵,并且可以正常工作。对于“中位数”集群,这是我的代码:
DM_euclid <- get_dist(Ind, method = "euclidean", stand
= T)##Ind. is a dataframe 58 obs., 19 variables with
rownames and colnames and data only numbers
dend_median <- hclust(DM_euclid, method="median")
###this was a test and is working##
plot(dend_median, xlab="Städte",ylab="Distanzen",
main="Dendogramm der Clusteranalyse (Single)",
labels=FALSE)
##this is what causes the error####
(fviz_dend(dend_median, k = 5,
cex = 0.5,
k_colors = c("#2E9FDF", "#00AFBB",
"#E7B800", "#FC4E07", "lightgreen"),
color_labels_by_k = TRUE,
rect = TRUE, xlab = "", ylab = "Distanzen"))
有人知道我的问题可能是什么原因吗?还是只是解决方案? :D
非常感谢您!!
干杯!