Last chance! 50% off unlimited learning
Sale ends in
cumsum(x)
cumprod(x)
cummax(x)
cummin(x)
cummin
or cummax
)
object, or an object that can be coerced to one of these.x
(after coercion),
except that cumprod
returns a numeric vector for integer input
(for consistency with *
). Names are preserved.An NA
value in x
causes the corresponding and following
elements of the return value to be NA
, as does integer overflow
in cumsum
(with a warning).
cumsum
and cumprod
are S4 generic functions:
methods can be defined for them individually or via the
Math
group generic.
cummax
and cummin
are individually S4 generic functions.Math
group generic.
cumsum
only.)
cumsum(1:10)
cumprod(1:10)
cummin(c(3:1, 2:0, 4:2))
cummax(c(3:1, 2:0, 4:2))
Run the code above in your browser using DataLab