Learn R Programming

matrixStats (version 0.12.2)

rowDiffs: Calculates difference for each row (column) in a matrix

Description

Calculates difference for each row (column) in a matrix.

Usage

rowDiffs(x, ...)
 colDiffs(x, ...)

Arguments

x
...
Not used.

Value

See Also

Internally diff() is used.

Examples

Run this code
x <- matrix(1:27, ncol=3)

d1 <- rowDiffs(x)
print(d1)

d2 <- t(colDiffs(t(x)))
stopifnot(all.equal(d2, d1))

Run the code above in your browser using DataLab