\HeaderA{cumsum}{Cumulative Sums, Products, and Extremes}{cumsum}
\aliasA{cummax}{cumsum}{cummax}
\aliasA{cummin}{cumsum}{cummin}
\aliasA{cumprod}{cumsum}{cumprod}
\keyword{arith}{cumsum}
\begin{Description}\relax
Returns a vector whose elements are the cumulative sums, products,
minima or maxima of the elements of the argument.
\end{Description}
\begin{Usage}
\begin{verbatim}
cumsum(x)
cumprod(x)
cummax(x)
cummin(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a numeric or complex (not \code{cummin} or \code{cummax})
object, or an object that can be coerced to one of these.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
These are generic functions: methods can be defined for them
individually or via the \code{\LinkA{Math}{Math}} group generic.
\end{Details}
\begin{Value}
A vector of the same length and type as \code{x} (after coercion),
except that \code{cumprod} returns a numeric vector for integer input
(for consistency with \code{*}).  Names are preserved.

An \code{NA} value in \code{x} causes the corresponding and following
elements of the return value to be \code{NA}, as does integer overflow
in \code{cumsum} (with a warning).
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole. (\code{cumsum} only.)
\end{References}
\begin{Examples}
\begin{ExampleCode}
cumsum(1:10)
cumprod(1:10)
cummin(c(3:1, 2:0, 4:2))
cummax(c(3:1, 2:0, 4:2))
\end{ExampleCode}
\end{Examples}

