按日期范围和 ID、面板数据联合

Joint by date range and ID ,panel data

我有基础基金数据,我想按日期范围和基金ID添加管理人姓名

我试过模糊右连接 x = fuzzy_right_join(manager, fundret, by = c("fundName" = "fundName", "date"= "managerStartdate", "date" = "managerENDdate"), match_fun = list('==', '>', '<')) 但是有一个错误

Error in mf(rep(u_x, n_y), rep(u_y, each = n_x), ...) :could not find function "mf

我试了一些If /else函数,还是不行......

library(lubridate)
manager=data.frame(managerName=c("A","B","C","D","E","F","G","H","I","J","K","L","M","N"),
                   fundName=c("fundA","fundA","fundA","fundA","fundA","fundA","fundA","fundA","fundA","fundA","fundA","fundB","fundB","fundC"),
                   managerStartdate=ymd(c("20040227","20041218","20140317","20140317","20120405","20151119","20140620","20150901","20100118","20150107","20051029","20140321","20130320","20140321")),
                   mangerENDdate=ymd(c("20051029","20050412","20151119","20170113","20130628","20170224","20150107","20170328","20140620","NA","20100118","20180912","20140430","20180912")))


fundret=data.frame(
                   fundName=c("fundA","fundA","fundA","fundA","fundA","fundA","fundB","fundC"),
                   date=ymd(c("20020628","20041003","20120508","20140321","20160101","20170201","20140707","20170909")),
                   ret=c(0.05,0.3,0.44444,0.00023,-0.0058,0.00006,-0.5,0.7))

这是我想联合的

wantedresult=data.frame(
  fundName=c("fundA","fundA","fundA","fundA","fundA","fundA","fundB","fundC"),
  date=ymd(c("20020628","20041003","20120508","20140321","20160101","20170201","20140707","20170909")),
  ret=c(0.05,0.3,0.44444,0.00023,-0.0058,0.00006,-0.5,0.7),
  managerName=c("NA","A","I&E","C&D","D&J","J","L","N"))

感谢您的帮助

经理:https://i.stack.imgur.com/sbfk7.jpg

基金:https://i.stack.imgur.com/aQyj1.jpg

想要的结果:https://i.stack.imgur.com/DbWap.jpg

如果您在 match_fun 参数中使用反引号而不是引号,它应该可以工作。

match_fun = list(backtick==backtick, backtick>backtick, backtick

反引号=`