\Header{identify.hclust}{Identify Clusters in a Dendrogram}
\keyword{cluster}{identify.hclust}
\keyword{iplot}{identify.hclust}
\begin{Description}\relax
\code{identify.hclust} reads the position of the graphics pointer when the
(first) mouse button is pressed.  It then cuts the tree at the
vertical position of the pointer and highlights the cluster containing
the horizontal position of the pointer. Optionally a function is
applied to the index of data points contained in the cluster.\end{Description}
\begin{Usage}
\begin{verbatim}
identify.hclust(HCOBJ, FUN=NULL, N=20, MAXCLUSTER=20, DEV.FUN=NULL, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{HCOBJ}] an object of the type produced by \code{hclust}.
\item[\code{FUN}] (optional) function to be applied to the index numbers of
the data points in a cluster (see Details below).
\item[\code{N}] the maximum number of clusters to be identified.
\item[\code{MAXCLUSTER}] The maximum number of clusters that can be produced
by a cut (limits the effective vertical range of the pointer). 
\item[\code{DEV.FUN}] (optional) integer scalar. If specified, the
corresponding graphics device is amde active before \code{FUN} is
applied.
\item[\code{...}] further arguments to \code{FUN}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
By default clusters can be identified using the mouse and an
\code{\Link{invisible}} list of indices of the respective data points
is returned. 

If \code{FUN} is not \code{NULL}, then the index vector of data points
is passed to this function as first argument, see the examples
below. If active graphics device for \code{FUN} can be specified using
\code{DEV.FUN}.

The identification process is terminated by pressing any mouse
button other than the first, or by clicking outside the graphics
window.\end{Details}
\begin{Value}
Either a list of data point index vectors or a list of return values
of \code{FUN}.\end{Value}
\begin{Examples}
\begin{ExampleCode}

library(mva)
data(USArrests)
hca <- hclust(dist(USArrests))
plot(hca)
x <- identify.hclust(hca)
x

data(iris)
hci <- hclust(dist(iris[,1:4]))
plot(hci)
identify.hclust(hci, function(k) print(table(iris[k,5])))

x11()
dev.set(2)
plot(hci)
identify.hclust(hci, function(k) barplot(table(iris[k,5])), DEV.FUN=3)

\end{ExampleCode}
\end{Examples}

