find_max_ind: Finds the max index in a vector that does not exceed a target...

Description Usage Arguments Value Examples

View source: R/Score_init.R

Description

Finds the max index in a vector that does not exceed a target number.

Usage

1
find_max_ind(vals, target, start = 1)

Arguments

vals

A vector of numbers.

target

A number. Must not be smaller than vals[start].

start

A number, the starting index; default to 1. Must be such that vals[start] <= target.

Value

The max index i such that vals[i] <= target and i >= start.

Examples

1
2
3
4
5
6
7
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()
}

genscore documentation built on April 28, 2020, 1:06 a.m.