У меня есть базовые данные фонда, я хочу добавить имя управляющего по диапазону дат и идентификатор фонда
Я попробовал нечеткое правое соединение
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
fundret: https://i.stack.imgur.com/aQyj1.jpg
wantedresult: https://i.stack.imgur.com/DbWap.jpg