ifirstHit
Syntax
ifirstHit(func, X, target)
Arguments
func can only be the following operators: >, >=, <, <=, !=, <>, ==.
X is a vector/matrix/table.
target is a scalar of the same type as X indicating the value to be compared with X.
Details
Return the index of the first element in X that satisfies the condition X func target
(e.g. X>5).
If no element in X satisfies the condition, return -1.
NULL values are ignored in ifirstHit
.
Use ifirstNot to find the index of the first non-NULL value.
Use find to find the index of the first NULL value.
Examples
1 $ X = NULL 3.2 4.5 1.2 NULL 7.8 0.6 9.1
2 $ ifirstHit(<, X, 2.5)
3 3
4
5 // return -1 if no element in X satisfies the condition.
6 $ ifirstHit(>, X, 10.0)
7 -1
Related function: firstHit