
Find Interval Numbers or Indices and Return Custom Number For 0.
Source:R/helpers.R
h_find_interval.RdA simple wrapper of findInterval() function that invokes
findInterval(), takes its output and replaces all the
elements with \(0\) value to a custom number as specified in replacement
argument.
Arguments
- ...
-
Arguments passed on to
base::findIntervalxnumeric.
vecnumeric, sorted (weakly) increasingly, of length
N, say.rightmost.closedlogical; if true, the rightmost interval,
vec[N-1] .. vec[N]is treated as closed, see below.all.insidelogical; if true, the returned indices are coerced into
1,...,N-1, i.e.,0is mapped to1andNtoN-1.left.openlogical; if true all the intervals are open at left and closed at right; in the formulas below, \(\le\) should be swapped with \(<\) (and \(>\) with \(\ge\)), and
rightmost.closedmeans ‘leftmost is closed’. This may be useful, e.g., in survival analysis computations.checkSortedlogical indicating if
vecshould be checked, i.e.,is.unsorted(vec)is asserted to be false. Setting this toFALSEskips the check gaining speed, but may return nonsense results in casevecis not sorted.checkNAlogical indicating if each
x[i]should be checked as withis.na(.). Setting this toFALSEin case ofNA's inx[]may result in platform dependent nonsense.
- replacement
(
number)
a custom number to be used as a replacement for \(0\). Default to-Inf.