I am trying to join two table in R. Since the joiner is not unique for both of the table so there is a chance of duplicate values. To mitigate this duplicate I like to add some conditions within the joining statement.
My hypothetical approach is as follows: where I like to join the DF and GF by id where they have only the mentioned condition such as: DF's Incomedate= GF's Outgoingdate, FD's Incomedate = Gf's Outgoingday + 1day and DF's REFID=1000. ```
DF_new <- DF %>%
left_join(GF, by c('id'='id','Incomedate'='Outgoingdate','Incomedate'=as.date('Outgoingdate'+1),REFId=1000)
I can do it in SQL as follows:
DF LEFTJOIN GF on DF.[id]=GF.[id] and (DF.Incomedate=GF.Outgoingdate or
DATEADD(DAY,1,GF.[Outgoingdate])=DF.Incomingdate and (REFID=1000)
How can I replicate it in R?