findnearest: Find the nearest observation to another observation

Description Usage Arguments Value Functions References

View source: R/findnearest.R

Description

This function finds the nearest y to every x. Y's may be duplicated.

Usage

1
2
3
4
findnearest(x, y, direction = c("both", "ascending", "descending"),
  returnIndex = FALSE)

getlower(x, y, upper = FALSE)

Arguments

x

a vector to find matches for

y

a vector to find the matches

direction

default = both, ascending for only y matches before x and descending for only y matches after x.

returnIndex

should an index of the mathced y values be returned instead of the matched list.

upper

upper value?

Value

a list of length 2 with a y matched to every x, note if direction = 'ascending' or 'descending', NAs will be returned for x values with no y values before or after, respectively. OR an index of matched y values if returnIndex = TRUE.

indexes of y for each x

Functions

References

This function borrowed heavily from this stack exchange post: https://stats.stackexchange.com/questions/161379/quickly-finding-nearest-time-observation


ledbettc/CIDAtools documentation built on Jan. 24, 2020, 3:56 p.m.