I am trying to create a new value in df_test based on if a row has been found in a second dataframe with 3 conditions being true. The conditions are as follows:
- The names must be equal in both tables (df_test$name = df_prod$name)
- The df_prod$birthdate must be at least 2020-01-01 (the persons birthdate can not be earlier than 2020-01-01)
- The df_test$import_date must be smaller than the df_prod$sent_date
I think of it as a Vlookup with multiple conditions.
This is what I have so far:
df_test$V5 = case_when(df_test$name %in% df_prod$name & df_test$import_date < df_prod$sent_date & df_prod$birthday > as.Date('2020-01-01') & ~ 1, TRUE ~ 0) Does anyone know how to proceed?