Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nearestReftoX

Find Nearest Element of Reference for each Element of X


Description

Find nearest element of a sorted reference vector and to each element of x.

Usage

nearestReftoX(x, reference, ...)

Arguments

x

numeric vector.

reference

numeric vector, sorted in increasing order.

...

other arguments as passed to findInterval.

Details

This function finds the element of a reference table (reference) that is closest to each element of an incoming vector (x).

The function is a simple wrapper for findInterval in the base package. It calls findInterval with vec equal to the mid-points between the reference values.

Value

Integer vector giving indices of elements of reference.

Author(s)

Gordon Smyth

See Also

Examples

nearestReftoX(c(-10,0.5,0.6,2,3), reference = c(-1,0,2))

edgeR

Empirical Analysis of Digital Gene Expression Data in R

v3.32.1
GPL (>=2)
Authors
Yunshun Chen, Aaron TL Lun, Davis J McCarthy, Matthew E Ritchie, Belinda Phipson, Yifang Hu, Xiaobei Zhou, Mark D Robinson, Gordon K Smyth
Initial release
2021-01-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.