
Find Interval Numbers or Indices and Return Custom Number For 0.
Source:R/helpers.R
h_find_interval.Rd
A 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::findInterval
x
numeric.
vec
numeric, sorted (weakly) increasingly, of length
N
, say.rightmost.closed
logical; if true, the rightmost interval,
vec[N-1] .. vec[N]
is treated as closed, see below.all.inside
logical; if true, the returned indices are coerced into
1,...,N-1
, i.e.,0
is mapped to1
andN
toN-1
.left.open
logical; 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.closed
means ‘leftmost is closed’. This may be useful, e.g., in survival analysis computations.checkSorted
logical indicating if
vec
should be checked, i.e.,is.unsorted(vec)
is asserted to be false. Setting this toFALSE
skips the check gaining speed, but may return nonsense results in casevec
is not sorted.checkNA
logical indicating if each
x[i]
should be checked as withis.na(.)
. Setting this toFALSE
in 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
.