R 中的 Nbclust 函数:需要 numeric/complex matrix/vector 个参数

Nbclust function in R: requires numeric/complex matrix/vector arguments

我正在尝试执行层次聚类,我想使用 nbclust 来确定最佳聚类数。但是,我不断收到以下错误:

Error in t(jeu) %*% jeu : requires numeric/complex matrix/vector arguments

我已经生成了相异矩阵并绘制了树状图。我的数据集包含 2 个数值变量和 260 个观测值。

我尝试了其他问题中建议的几个解决方案,例如不在函数中包含数据并且仅使用相异矩阵但我收到以下错误:

Data matrix is needed. Only frey, mcclain, cindex, sihouette and dunn can be computed.

我一直在使用的代码如下:

dist.gower <- daisy(mydata, metric = "gower")

aggl.clust.c <- hclust(dist.gower, method = "complete")
plot(aggl.clust.c,
     main = "Agglomerative, complete linkages")

NbClust(mydata, diss="dist.gower", method= "complete", index="all")

树状图绘制成功,但我不断收到此错误消息:

Error in t(jeu) %*% jeu : requires numeric/complex matrix/vector arguments

Data matrix is needed. Only frey, mcclain, cindex, sihouette and dunn can be computed.

这指的是 事实 某些索引(除上述索引外的所有索引)需要 坐标数据。查看索引的定义!

由于某些指标没有坐标就无法计算,index="all"无效。

使用 index="silhouette" 错误应该会消失。