(dfa <- data.frame(
stringsAsFactors = FALSE,
Key = c(1L, 2L, 3L, 4L, 5L),
Date = c("2020-01-01",
"2017-08-25","2016-04-04","2015-01-04","2016-09-15"),
toyCategory= c("toy1", "toy2", "toy2", "toy3", "toy1")
))
(dfb <- data.frame(
stringsAsFactors = FALSE,
Description = c("toy3", "toy2", "toy1", "toy1", "toy2"),
Num_Rate = c(0.9, 1.1, 1.2, 1, 1.24),
EffectiveDate = c("2015-01-01","2016-08-16",
"2016-01-01","2016-1a-16","2015-02-15"),
ExpiryDate = c("2015-12-31","2017-08-31",
"2016-10-15","2999-12-31","2016-08-15")
))
library(fuzzyjoin)
fuzzy_left_join(dfa,
dfb,
by=c("toyCategory"="Description",
"Date"="EffectiveDate",
"Date"="ExpiryDate"),
match_fun=list(`==`,`>=`,`<=`)
)