Create a little dude to perform hierarchical clustering in a semi-global context using the hclust package.
Create a little dude to perform hierarchical clustering in a semi-global context using the hclust package.
hierarchical_clusterer(method)
Arguments
method: A string to pass to hclust to tell it what kind of clustering to do.
Returns
A function that inputs a list of distance matrices and returns a list containing one vector per bin, whose element names are data point names and whose values are cluster labels (within each bin).
Details
This clusterer determines cutting heights for bin dendrograms generated by hclust by first considering the tallest branches across all dendrograms; if all branch heights of a given dendrogram are below a threshold (10 percent of the global tallest), that dendrogram will be considered to describe a single cluster. Additionally, if the index of dispersion of the branch heights of a dendrogram are below 0.015, we will also consider it as describing a single cluster. If neither of these are true, then we will cut the dendrogram at its longest branch.