dateDists: date function for matching

Description Usage Arguments Details Value Examples

Description

date function for matching

Usage

1
2
dateDists(dat1, dat2 = NULL, dat1Format = "mdy", dat2Format = "mdy",
  threshold = 0L)

Arguments

dat1, dat2

a vector of dates to match

dat1Format, dat2Format

format of dates to pass to lubridate in the form of "mdy" or "ymd" etc.

threshold

in days, otherwise returns scaled values

Details

The formats for dates are passed to lubridate's function parse_date_time, so they need to be in the format "mdy" or "ymd", etc.

Value

a pairwise matrix of scores from 0 (exact match) to 1 (no match)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Two data sets in Month-Day-Year and Year-Month-Day format, respectively.
# Note that the way the dates can vary within data sets, but it's assumed
# that the order within a data set is consistant.

test1 <- data.frame(x = c("Jan-21-01", "01-25-02"), stringsAsFactors = FALSE)
test2 <- data.frame(x = c("01-JAN-21", "2001-Jan-31"), stringsAsFactors = FALSE)

# match dates within 11 days of each other
dateDists(test1, test2, dat1Format = "mdy", dat2Format = "ymd", threshold = 11)

# exact match of dates
dateDists(test1, test2, dat1Format = "mdy", dat2Format = "ymd")

# relative distance of dates by setting threshold to NULL
dateDists(test1, test2, dat1Format = "mdy", dat2Format = "ymd", threshold = NULL)

Hackout3/epimatch documentation built on May 6, 2019, 9:48 p.m.