rowDiffs | R Documentation |
Calculates difference for each row (column) in a matrix.
rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L,
dim. = dim(x), ..., useNames = TRUE)
colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L,
dim. = dim(x), ..., useNames = TRUE)
x |
An NxK |
rows |
A |
cols |
A |
lag |
An |
differences |
An |
dim. |
An |
... |
Not used. |
useNames |
If |
Returns a numeric
Nx(K-1) or (N-1)xK
matrix
.
Henrik Bengtsson
See also diff2
().
x <- matrix(1:27, ncol = 3)
d1 <- rowDiffs(x)
print(d1)
d2 <- t(colDiffs(t(x)))
stopifnot(all.equal(d2, d1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.