powered by
Calculates difference for each row (column) in a matrix.
rowDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ...)colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ...)
colDiffs(x, rows = NULL, cols = NULL, lag = 1L, differences = 1L, dim. = dim(x), ...)
A numeric NxK matrix.
numeric
matrix
A vector indicating subset of rows (and/or columns) to operate over. If NULL, no subsetting is done.
vector
NULL
An integer specifying the lag.
integer
An integer specifying the order of difference.
An integer vector of length two specifying the dimension of x, also when not a matrix.
x
Not used.
Returns a numeric Nx(K-1) or (N-1)xK matrix.
See also diff2().
diff2
# NOT RUN { 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