I have a data set of animals passing an RFID reader, it looks like this -
ID date_time
A 2019-11-02 08:07:47
B 2019-11-02 08:07:48
A 2019-11-02 08:07:49
A 2019-11-02 08:07:50
A 2019-11-02 08:09:12
A 2019-11-02 08:09:13
B 2019-11-02 08:09:17
I asked this question recently, (combine multiple rows into one time interval), and now my data looks like this - (with the data organised into ten second intervals)
ID start_date_time. end_date_time
A 2019-11-02 08:07:47 2019-11-02 08:07:50
B 2019-11-02 08:07:48 2019-11-02 08:07:48
A 2019-11-02 08:09:12 2019-11-02 08:09:13
B 2019-11-02 08:09:17 2019-11-02 08:09:47
I have also added a column which summarises the intervals
dat$Interval = interval(dat$start_date_time,dat$end_date_time)
I now need to find and summarise where these intervals intersect and produce this as a count, to show the number of times animals interact (or are present at the RFID reader at the same time) something like this - (and without repeating reverse interactions, i.e. A-B, B-A)
ID ID2 Interactions(n)
A A 0
A B 1
A C 3
Any help appreciated.