nearest.to: Select the nearest point in an array to a given value
Description
Similar to the base function match() but allows for data where you
won't find an exact match. Selects the nearest value from 'array' to the
value 'point'. Sometimes there are multiple points with equal distance
in which case choose from 3 possible 'dispute.method's for choosing
which of the equidistant array values to index.
returns the index of 'array' to which 'point' is nearest.
Usage
nearest.to(array, point, dispute.method = c("first", "last", "random"))
Value
index value of the nearest point in 'array'.
Arguments
array
a numeric vector or POSIXct vector of date-times.
point
the value that you want to find the nearest point to.
dispute.method
when there are equidistant values to 'point' in
array, choose either the first, last, or a random select, based
on the original order in 'array.