\HeaderA{tabulate}{Tabulation for Vectors}{tabulate}
\keyword{arith}{tabulate}
\begin{Description}\relax
\code{tabulate} takes the integer-valued vector \code{bin} and counts
the number of times each integer occurs in it.
\end{Description}
\begin{Usage}
\begin{verbatim}
tabulate(bin, nbins = max(1, bin))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{bin}] a numeric vector (of positive integers), or a factor.
\item[\code{nbins}] the number of bins to be used.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{tabulate} is used as the basis of the \code{\LinkA{table}{table}} function.

If \code{bin} is a factor, its internal integer representation
is tabulated.

If the elements of \code{bin} are numeric but not integers,
they are truncated to the nearest integer.
\end{Details}
\begin{Value}
An integer vector (without names).  There is a bin for each of the
values \code{1, ..., nbins}; values outside that range are (silently)
ignored.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{table}{table}}, \code{\LinkA{factor}{factor}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
tabulate(c(2,3,5))
tabulate(c(2,3,3,5), nbins = 10)
tabulate(c(-2,0,2,3,3,5))  # -2 and 0 are ignored
tabulate(c(-2,0,2,3,3,5), nbins = 3)
tabulate(factor(letters[1:10]))
\end{ExampleCode}
\end{Examples}

