\Header{max.col}{Find Maximum Position in Matrix}
\keyword{utilities}{max.col}
\keyword{array}{max.col}
\begin{Description}\relax
Find the maximum position for each row of a matrix, breaking ties at random.\end{Description}
\begin{Usage}
\begin{verbatim}
max.col(m)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{m}] numerical matrix
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Ties are broken at random.  The determination of ``tie'' assumes that
the entries are probabilities.\end{Details}
\begin{Value}
index of a maximal value for each row, an integer vector of
length \code{nrow(m)}.\end{Value}
\begin{Author}\relax
W. N. Venables and B. D. Ripley\end{Author}
\begin{References}\relax
Venables, W. N. and Ripley, B. D. (1999)
\emph{Modern Applied Statistics with S-PLUS.}
New York: Springer (3nd ed).\end{References}
\begin{SeeAlso}\relax
\code{\Link{which.max}} for vectors.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(swiss)
table(mc <- max.col(swiss))# mostly "1" and "5", 5 x "2" and once "4"
swiss[unique(print(mr <- max.col(t(swiss)))) , ] # 3 33 45 45 33 6
\end{ExampleCode}
\end{Examples}

