EVOLUTION-MANAGER
Edit File: cutree.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Cut a Tree into Groups of Data</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for cutree {stats}"><tr><td>cutree {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Cut a Tree into Groups of Data</h2> <h3>Description</h3> <p>Cuts a tree, e.g., as resulting from <code><a href="hclust.html">hclust</a></code>, into several groups either by specifying the desired number(s) of groups or the cut height(s). </p> <h3>Usage</h3> <pre> cutree(tree, k = NULL, h = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>tree</code></td> <td> <p>a tree as produced by <code><a href="hclust.html">hclust</a></code>. <code>cutree()</code> only expects a list with components <code>merge</code>, <code>height</code>, and <code>labels</code>, of appropriate content each.</p> </td></tr> <tr valign="top"><td><code>k</code></td> <td> <p>an integer scalar or vector with the desired number of groups</p> </td></tr> <tr valign="top"><td><code>h</code></td> <td> <p>numeric scalar or vector with heights where the tree should be cut.</p> </td></tr> </table> <p>At least one of <code>k</code> or <code>h</code> must be specified, <code>k</code> overrides <code>h</code> if both are given. </p> <h3>Details</h3> <p>Cutting trees at a given height is only possible for ultrametric trees (with monotone clustering heights). </p> <h3>Value</h3> <p><code>cutree</code> returns a vector with group memberships if <code>k</code> or <code>h</code> are scalar, otherwise a matrix with group memberships is returned where each column corresponds to the elements of <code>k</code> or <code>h</code>, respectively (which are also used as column names). </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="hclust.html">hclust</a></code>, <code><a href="dendrogram.html">dendrogram</a></code> for cutting trees themselves. </p> <h3>Examples</h3> <pre> hc <- hclust(dist(USArrests)) cutree(hc, k = 1:5) #k = 1 is trivial cutree(hc, h = 250) ## Compare the 2 and 4 grouping: g24 <- cutree(hc, k = c(2,4)) table(grp2 = g24[,"2"], grp4 = g24[,"4"]) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>