which_closest: Find Index of Closest Element

Description Usage Arguments Value Examples

View source: R/which_closest.R

Description

Used to find the index of the element of a vector x with the value closest to y, regardless of whether it is greater or less than y.

Usage

1

Arguments

x

A numeric vector with length > 1 from which to find an element index.

y

A numeric vector with length == 1, the "close to" value.

Value

a numeric vector with length 1, which represents the index of x that is closest to the value y.

Examples

1
which_closest(x = 5:10, y = 7)

bstaton1/StatonMisc documentation built on May 18, 2020, 12:06 a.m.