我正在尝试进行一些分组并遇到此错误。
Evaluation error: the 'height' component of 'tree' is not sorted (increasingly).
我的输入是:
library(stringdist)
name <- c("luke,abcdef","luke,abcdeh","luke,abcdeg")
a<-stringdistmatrix(name, method="jw")
clusts <- hclust(a, method="ward.D2")
但是当我尝试剪切它时,它给了我一个错误:
> cutree(clusts, h = 0.155)
Error in cutree(clusts, h = 0.155) :
the 'height' component of 'tree' is not sorted (increasingly)
但是如果我使用
a<-stringdistmatrix(name, method="jw", p=0.05)
一切正常。
我一直在寻找解决方案,但找不到。我应该怎么做,以防止这种情况发生并保持工作?
我还注意到,如果我有相同的距离矩阵,但是是手动生成的(所以集群中没有距离参数。