Library: | xplore |
See also: | tdiff |
Quantlet: | diff | |
Description: | computes first differences (along the rows) of an array. |
Usage: | dx = diff(x) | |
Input: | ||
x | d1 x d2 x ... x dn array | |
Output: | ||
dx | (d1-1) x d2 x ... x dn array, first differences along the rows of x. |
library("xplore") x =(1:4)|6 diff(x)
Contents of dx [1,] 1 [2,] 1 [3,] 1 [4,] 2
library("xplore") x = matrix(3, 2, 2) x[1, 1, 1] = 2 x[2, 2, 2] = 3 diff(x)
Contents of dx [,,1,1,1,1,1,1] [1,] -1 0 [2,] 0 0 [,,2,1,1,1,1,1] [1,] 0 2 [2,] 0 -2