indexesInRange {bsearchtools} | R Documentation |
Find indexes in a range using binary search
Description
Given a sorted vector, it returns the indexes of the vector elements included in range [lbInclusive,ubInclusive].
The functions suffixed with the vector type (indexInRangeNumeric,indexInRangeLogical etc.) can be used ONLY with the specified type, otherwise the vector is coerced, and they are (hopefully negligibly) faster then the generic indexInRange function.
Usage
indexesInRange(sortedValues,lbInclusive, ubInclusive,indexesRemap=NULL)
indexesInRangeNumeric(sortedValues,lbInclusive, ubInclusive,indexesRemap=NULL)
indexesInRangeInteger(sortedValues,lbInclusive, ubInclusive,indexesRemap=NULL)
indexesInRangeLogical(sortedValues,lbInclusive, ubInclusive,indexesRemap=NULL)
indexesInRangeCharacter(sortedValues,lbInclusive, ubInclusive,indexesRemap=NULL)
Arguments
sortedValues |
A sorted atomic vector of type numeric, integer, logical or character |
lbInclusive |
The inclusive lower bound of the range |
ubInclusive |
The inclusive upper bound of the range |
indexesRemap |
An integer vector to be used to remap the indexes returned by lookup on sortedValues, or NULL (the default). Mostly used internally by DFI. |
Value
The indexes of the vector elements included in range [lbInclusive,ubInclusive].
Examples
indexesInRange(c(1,4,5,5,7,9),5,7) # returns c(3,4,5)
indexesInRange(c(1,4,5,5,7,9),10,11) # returns empty vector
[Package bsearchtools version 0.0.61 Index]