Объединение по диапазону дат и идентификатору, данным панели

У меня есть основные данные фонда, я хочу добавить имя управляющего по диапазону дат и идентификатору фонда

Я попробовал нечеткое право присоединиться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"))

Спасибо за вашу помощь

менеджер:

фундрет:

wantedresult:

0 ответов

Если вы используете обратные кавычки вместо кавычек в аргументах match_fun, это должно работать.

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

backtick = `

Другие вопросы по тегам