title: R cut dendrogram into groups with minimum size
body: <p>Is there an easy way to calculate lowest value of <code>h</code> in <code>cut</code> that produces groupings of a given minimum size?</p>
  
  <p>In this example, if I wanted clusters with at least ten members each, I should go with <code>h = 3.80</code>:</p>
  
  <pre><code># using iris data simply for reproducible example
  data(iris)
  d &lt;- data.frame(scale(iris[,1:4]))
  hc &lt;- hclust(dist(d))
  plot(hc)
  
  cut(as.dendrogram(hc), h=3.79) # produces 5 groups; group 4 has 7 members
  
  cut(as.dendrogram(hc), h=3.80) # produces 4 groups; no group has &lt;10 members
  </code></pre>
  
  <p>Since the heights of the splits are given in <code>hc$height</code>, I could create a set of candidate values using <code>hc$height + 0.00001</code> and then loop through cuts at each of them.  However, I don't see how to parse the cluster size <code>members</code> out of the <code>dendrogram</code> class.  For example, <code>cut(as.dendrogram(hc), h=3.80)$lower[[1]]$members</code> returns <code>NULL</code>, not 66 as desired. </p>
  
  <p>Please note that this is a simpler question than <a href="https://stackoverflow.com/questions/19734381/cutting-dendrogram-into-n-trees-with-minimum-cluster-size-in-r">Cutting dendrogram into n trees with minimum cluster size in R</a> which uses the package <code>dynamicTreeCut</code>; here I am not specifying number of trees, just minimum cluster size.  TYVM.</p>