Description Usage Arguments Value Functions References
This function finds the nearest y to every x. Y's may be duplicated.
1 2 3 4 | findnearest(x, y, direction = c("both", "ascending", "descending"),
returnIndex = FALSE)
getlower(x, y, upper = FALSE)
|
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? |
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
getlower
: function for finding lower(upper) value
This function borrowed heavily from this stack exchange post: https://stats.stackexchange.com/questions/161379/quickly-finding-nearest-time-observation
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.