Cut a hierarchical tree targeting k clusters

cut_clusters(clusters, k)

Arguments

clusters

cluster results, produced by e.g. fastcluster::hclust()

k

target number of clusters

Value

cluster labels

Examples

dmat <- compute_dmat(iris, "euclidean", TRUE, c("Petal.Length", "Sepal.Length"))
clusters <- compute_clusters(dmat, "complete")
cluster_labels <- cut_clusters(clusters, 2)
head(cluster_labels)
#> [1] 1 1 1 1 1 1