find_max_ind {genscore} | R Documentation |
Finds the max index in a vector that does not exceed a target number.
Description
Finds the max index in a vector that does not exceed a target number.
Usage
find_max_ind(vals, target, start = 1)
Arguments
vals |
A vector of numbers. |
target |
A number. Must not be smaller than |
start |
A number, the starting index; default to 1. Must be such that |
Value
The max index i
such that vals[i] <= target
and i >= start
.
Examples
for (i in 1:100) {
vals <- 1:i
for (start in 1:i)
for (target in seq(start, i+0.5, by=0.5))
if (find_max_ind(vals, target, start) != floor(target))
stop()
}
[Package genscore version 1.0.2.2 Index]