This function is used to return the row index where x occurs in a strictly monotonic dataset, according to condition defined by ctrl.
double Index(double x, vector vdata[, int ctrl])
- is any real number.
- is the strictly monotonic vector data.
- is used to control the index position, which has three options
- 0(default) : Equal or closest
- 1 : Equal or less than
- 2 : Equal or greater than
For data which is monotonically decreasing, the meaning of 1 and 2 are reversed.
Returns the row index where x occurs in vdata according to the ctrl condition. If vdata is not strictly monotonic, has missing values or the data is text, the return value is -2.
// Test for value that does not exist in the data
ind0=; // Should return 18 since (170 - 162) < (180.5 - 170)
ind1=; // Should return 18 since 170 should occur before (less than) row 19
ind2=; // Should return 19 since 170 should occur after (greater than)row 18
// Test for value that does exist in the data
// We can also pass a range variable
range raData = col(1);
ind0=; // Should return 20
ind1=; // Should return 20
ind2=; // Should return 20