match_near: Value matching based on closest value

View source: R/match_near.R

match_nearR Documentation

Value matching based on closest value

Description

match_near is similar to the base function match except match_near returns a vector of values or positions from y that are closest to the the vector of values in x. If two values in vectory are equally close to the value in x the first one is used.

Usage

match_near(x, y, tolerance = Inf, value = TRUE)

Arguments

x

Numeric vector of the values to be matched.

y

Numeric vector of the values to be matched against

tolerance

The maximum numeric difference between values in x and y to establish a match. If the difference exceeds the tolerance NA is returned for that match. The default tolerance is Inf which will return the closest value or position regardless of the absolute difference.

value

If TRUE, return the value of y instead of the position. Default is TRUE.

Details

The closest match in y to a given value in x is determined by the the value that has the minimum absolute difference between x and y. e.g. which.min(abs(x - y))

Value

vector of values or positions from y that are closest to the values in vector x.


DEQrmichie/heatsourcetools documentation built on Jan. 25, 2025, 2:31 p.m.