Differences between Matrix Rows
diffrows(x)
x | matrix |
---|
matrix with one row less than in input matrix x
and each row
i
representing the difference x[i+1, ]-x[i, ]
between rows
i+1
and i
in x
x <- matrix(1:12, nrow = 3) d <- diffrows(x) x[2, ] - x[1, ] == d[1, ]#> [1] TRUE TRUE TRUE TRUEx[3, ] - x[2, ] == d[2, ]#> [1] TRUE TRUE TRUE TRUE