Find values of one vector that are nearest to values in another vector.
Usage
which.nearest(x, y)
Arguments
x
vector of values to be compared against.
y
vector of values to examine relative to x. May be of length 1.
@return For each value in y, returns index of value of x which is
nearest to y in absolute value. In the case of ties, the function returns the
first index of x. If nearest value is min(x) or max(x), a warning is issued.
NAs and NaNs in x are ignored; NAs and NaNs in y are returned.