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

View source: R/Score_init.R

find_max_indR 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 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

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 May 29, 2024, 9 a.m.