Returns the index pointing to the first element in the vector that is not less than (i.e. greater or equal to) valueToSearch.
The behavior is the same as C++ std::lower_bound function, hence, if the vector is empty or valueToSearch is lower than
the first element of the vector, it returns the first index (i.e. 1).
The functions suffixed with the vector type (lbNumeric,lbLogical etc.) can be used ONLY with the specified type, otherwise the
vector is coerced, and they are (hopefully negligibly) faster then the generic lb function.
For information about NAs handling see details section.
A sorted atomic vector of type numeric, integer, logical or character.
valueToSearch
The value to search. If equal to NA, 1 is returned.
Value
The index pointing to the first element in the vector that is not less than (i.e. greater or equal to) valueToSearch.
Details
lb* functions expect sortedValues to be a vector sorted ascending (duplicated values are allowed).
Since the binary search functions rely on values comparison (using < operator) and NA cannot be compared by definition,
if sortedValues vector contains NA, the result is unpredictable and NO warning is given. Hence remove them before calling these functions.
References
See http://en.cppreference.com/w/cpp/algorithm/lower_bound