Learn R Programming

matrixStats (version 0.12.2)

rowCumsums: Cumulative sums, products, minima and maxima for each row (column) in a matrix

Description

Cumulative sums, products, minima and maxima for each row (column) in a matrix.

Usage

rowCumsums(x, dim.=dim(x), ...)
 colCumsums(x, dim.=dim(x), ...)
 rowCumprods(x, dim.=dim(x), ...)
 colCumprods(x, dim.=dim(x), ...)
 rowCummins(x, dim.=dim(x), ...)
 colCummins(x, dim.=dim(x), ...)
 rowCummaxs(x, dim.=dim(x), ...)
 colCummaxs(x, dim.=dim(x), ...)

Arguments

x
dim.
An integer vector of length two specifying the dimension of x, also when not a matr
...
Not used.

Value

See Also

See cumsum(), cumprod(), cummin(), and cummax().

Examples

Run this code
x <- matrix(1:12, nrow=4, ncol=3)
print(x)

yr <- rowCumsums(x)
print(yr)

yc <- colCumsums(x)
print(yc)

yr <- rowCumprods(x)
print(yr)

yc <- colCumprods(x)
print(yc)

yr <- rowCummaxs(x)
print(yr)

yc <- colCummaxs(x)
print(yc)

yr <- rowCummins(x)
print(yr)

yc <- colCummins(x)
print(yc)

Run the code above in your browser using DataLab