0

I have a list of objects (dataset 1), where each dataframe has the following structure, and where the filename corresponds to the ID (e.g: ID1.dat):

      date
      2018-10-23 20:20:00
      2018-10-23 20:21:00 
      2018-10-23 20:22:00
      2018-10-23 20:23:00
      2018-10-23 20:24:00
      2018-10-23 20:25:00
      ...................

and the other dataset is this dataframe (dataset 2):

   ID    date                   date2
   ID1   2019-03-15 09:43:30    2019-03-15 09:53:30
   ID2   2019-03-16 21:26:00    2019-03-16 21:36:00
   ID3   2019-03-17 10:25:40    2019-03-17 10:35:40
   ID4   2018-10-30 08:27:30    2018-10-30 08:37:30
   ID5   2018-10-30 16:57:10    2018-10-30 17:07:10
   ID6   2018-11-05 08:31:20    2018-11-05 08:41:20

   ...  .................... 

My goal is to create a new column at the end of each dataframe of the list (dataset 1) named 'match', that indicates if 'date' variable is between ‘date’ and ‘date2’ of the dataset 2, based on the ID.

Can someone help me?

Thank you very much! :)

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
EI_Stats
  • 21
  • 2
  • Good goal! What have you tried so far? – rdelrossi Feb 18 '22 at 16:56
  • `data.table` and `dplyr` solutions are found in this post: https://stackoverflow.com/questions/47721904/if-date-between-two-dates-in-second-table-return-value – algae Feb 18 '22 at 22:51
  • @El_Stats also see this post: https://stackoverflow.com/questions/31353595/checking-if-date-is-between-two-dates-in-r – Mel G Feb 21 '22 at 01:52

0 Answers0