1% File src/library/base/man/cumsum.Rd
2% Part of the R package, https://www.R-project.org
3% Copyright 1995-2009 R Core Team
4% Distributed under GPL 2 or later
5
6\name{cumsum}
7\alias{cumsum}
8\alias{cumprod}
9\alias{cummin}
10\alias{cummax}
11\title{Cumulative Sums, Products, and Extremes}
12\description{
13  Returns a vector whose elements are the cumulative sums, products,
14  minima or maxima of the elements of the argument.
15}
16\usage{
17cumsum(x)
18cumprod(x)
19cummax(x)
20cummin(x)
21}
22\arguments{
23  \item{x}{a numeric or complex (not \code{cummin} or \code{cummax})
24    object, or an object that can be coerced to one of these.}
25}
26\details{
27  These are generic functions: methods can be defined for them
28  individually or via the \code{\link[=S3groupGeneric]{Math}} group generic.
29}
30\value{
31  A vector of the same length and type as \code{x} (after coercion),
32  except that \code{cumprod} returns a numeric vector for integer input
33  (for consistency with \code{*}).  Names are preserved.
34
35  An \code{NA} value in \code{x} causes the corresponding and following
36  elements of the return value to be \code{NA}, as does integer overflow
37  in \code{cumsum} (with a warning).
38}
39\section{S4 methods}{
40  \code{cumsum} and \code{cumprod} are S4 generic functions:
41  methods can be defined for them individually or via the
42  \code{\link[=S4groupGeneric]{Math}} group generic.
43  \code{cummax} and \code{cummin} are individually S4 generic functions.
44}
45\references{
46  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
47  \emph{The New S Language}.
48  Wadsworth & Brooks/Cole. (\code{cumsum} only.)
49}
50\examples{
51cumsum(1:10)
52cumprod(1:10)
53cummin(c(3:1, 2:0, 4:2))
54cummax(c(3:1, 2:0, 4:2))
55}
56\keyword{arith}
57