Library: | xplore |
See also: | sum meanex |
Quantlet: | sumex | |
Description: | an extended form of the sum function - NaN and all values contained in excl are excluded from computation |
Usage: | sumx = sumex(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: | ||
sumx | 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(2, 4)) x[2,1] = NaN x excl = 2 sumex(x,excl)
Contents of x [1,] 3 1 7 4 [2,] +NAN 9 9 2 Contents of sumx [1,] 3 10 16 4