incompatibility of `dendextend::cutree` with `cluster` objects
GillesSanMartin opened this issue · 3 comments
Loading dendextend
causes cutree
to return an error when applied on cluster
obsjects (agnes
, diana
).
This breaks some other packages like clValid
.
Error in cutree.default(clusterObj, nc) :
Function cutree is only available for hclust/dendrogram/phylo objects only.
See for example this SO question (with reproducible example) :
https://stackoverflow.com/questions/52319709
Would it be possible to do something from dendextend to avoid that ?
Hi @GillesSanMartin ,
I've just pushed a new version of dendextend.
Before the fix:
> library(cluster)
> a <- diana(votes.repub, metric = "manhattan", stand = TRUE)
> dendextend::cutree(a, k=3)
Show Traceback
Rerun with Debug
Error in cutree.default(a, k=3) :
Function cutree is only available for hclust/dendrogram/phylo objects only.
After the fix:
library(cluster)
a <- diana(votes.repub, metric = "manhattan", stand = TRUE)
dendextend::cutree(a, k= 3)
> dendextend::cutree(a, k= 3)
Alabama Alaska Arizona Arkansas California Colorado Connecticut
1 2 3 1 3 3 3
Delaware Florida Georgia
etc...
Please confirm that it works for you as well?
Waouh that was quick !
It works indeed with the new dendextend 1.10.0
I will modify the SO answer to point to this better solution...
Thanks for the quick response and for developing such an excellent package !
My pleasure, thanks for the bug report :)