cumsum(x) cumprod(x)
x whose i-th value is the sum or product of the
first i values in
x.
This function will be used as the default method for classes that do not inherit a specific method for the function or for the Math group of functions. The result will retain the class and the attributes. If this behavior is not appropriate, the designer of the class should provide a method for the function or for the Math group
If the first
NA in
x is
x[j], the j-th
and all following elements of the value will be
NA.
A warning message is printed if
NAs are generated.
These are members of the
Math group of generic functions.
The
cumprod function performs arithmetic in double precision even if
x
has integer storage mode.
cumsum(1:6) # returns c(1, 3, 6, 10, 15, 21) cumprod(1:6) # returns c(1, 2, 6, 24, 120, 720)