date_near: Find Nearest Date within Threshold

Description Usage Arguments Value Examples

Description

Searches through vector of Dates for nearest match using given criteria according to function arguments.

sidepref must be filled in as 'l' or 'r' to receieve consistent results If sidepref is missing date_near will return one at random

Usage

1
2
date_near(dates, target, thresh = Inf, onlypre = F, sidepref,
  quiet = T)

Arguments

dates

vector of Date objects to search through

target

Date object to find nearest match

thresh

numeric value for threshold for maximum number of days between match

onlypre

logical for right censor of dates

sidepref

character for decision in case left and right side both have minimum distance

Value

Date object representing closest match to target Date object

Examples

1
2
3
4
5
6
x = seq.Date(from = as.Date("2010-01-01"), to = as.Date("2012-01-01"), length.out = 30)
y = as.Date("2011-01-01")
date_near(x,y, sidepref = 'l')
date_near(x,y, sidepref = 'r')
date_near(x,y, thresh = 1)
date_near(x,"2011-01-12", onlypre = T)

Ajfrick/AVRCHelp documentation built on May 28, 2019, 1:34 a.m.