I have two dataframes that I want to match in R.

Dataframe A has 24,300 cases with the following variables: Name, Gender, Age, DateTime_Event

Dataframe B has 3,000 cases with the following variables: ID, Gender, Age, Date_Time_Start, Date_Time_End

Note that cases from Dataframe B can be matched to more than one case in Dataframe A.

I want to match the two dataframes by copying the relative ID from Dataframe B to the corresponding row in Dataframe A based on age, gender, and date/time. Specifically, the matching criteria include all the following:

* The Gender and Age variables should exactly match in both dataframes.

* The DateTime_Event from Dataframe A should be between the Date_Time_Start and the Date_Time_End in Dataframe B.

Thank you!

Similar questions and discussions