\Header{cutree}{Cut a tree into groups of data}
\keyword{multivariate}{cutree}
\keyword{cluster}{cutree}
\begin{Description}\relax
Cuts a tree, e.g., as resulting from \code{\Link{hclust}}, into several
groups either by specifying the desired number of groups or the cut
height.\end{Description}
\begin{Usage}
\begin{verbatim}
cutree(tree, k=NULL, h=NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{tree}] a tree as produced by \code{\Link{hclust}}
\item[\code{k}] An integer scalar or vector with the desired number of groups
\item[\code{h}] A numeric scalar or vector with heights where the tree should
be cut.
\end{ldescription}

At least one of \code{k} or \code{h} must be specified, \code{k}
overrides \code{h} if both are given.\end{Arguments}
\begin{Value}
\code{cutree} returns an vector with group meberships if \code{k} or
\code{h} are scalar, otherwise a matrix with group meberships is returned
where each column corresponds to the elements of \code{k} or \code{h},
respectively (which are also used as column names).\end{Value}
\begin{SeeAlso}\relax
\code{\Link{hclust}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(mva)
data(USArrests)

hc <- hclust(dist(USArrests))

cutree(hc, k=2:5)
cutree(hc, h=250)
\end{ExampleCode}
\end{Examples}

