0

I have 2 data frames of unequal lengths, each with a column of timestamps. I would like to return the corresponding ID contained in df2 to df1 as a new column if the time difference is less than 60 minutes, meaning that so I know ID#1 in df2 with a specific appointment time are responsible for some of the entries in df1. Each ID should have 8 entries in df1.

To calculate the difference between each element in df1 and df2, I've tried

outer(df1$DataEntryTime, df2$ApptTime, '-')

and got a matrix of results.

enter image description here

What do I need to do next to build a conditional statement so it can return the ID# to df1 based on the results?

Many thanks!

kkwm
  • 1

0 Answers0