Returns the index pointing to the first element in the vector that is greater than valueToSearch.
The behavior is the same as C++ std::upper_bound function, hence, if the vector is empty it or if valueToSearch is greater than
the last element of the vector, it returns length(sortedValues) + 1.
The functions suffixed with the vector type (ubNumeric,ubLogical etc.) can be used ONLY with the specified type, otherwise the
vector is coerced, and they are (hopefully negligibly) faster then the generic ub 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, length(sortedValues)+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
ub* 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