Library: | xplore |
See also: | sum sumex |
Quantlet: | cumsumex | |
Description: | an extended form of the cumsum function - NaN and all values contained in excl are excluded from computation |
Usage: | csumx = cumsumex(x{, excl {, s}}) | |
Input: | ||
x | d1 x d2 x .. x dn array, n <= 7 | |
excl | a matrix containing values to be excluded | |
s | integer (number of dimension, default = 1) | |
Output: | ||
csumx | d1 x d2 x .. x d(j-1) x 1 x d(j+1) x .. x dn array |
library("xplore") randomize(666) x = rint(10 * uniform(5, 4)) x[2,1] = NaN x excl = #(2,4) cumsumex(x,excl)
Contents of x [1,] 3 9 5 3 [2,] +NAN 4 2 6 [3,] 1 2 7 8 [4,] 9 5 5 1 [5,] 7 1 3 5 Contents of csumx [1,] 3 9 5 3 [2,] +NAN -NAN -NAN 9 [3,] 4 -NAN 12 17 [4,] 13 14 17 18 [5,] 20 15 20 23