I have a dataset organized this way:
ID Species DateTime
P1 A 2015-03-16 18:42:00
P2 A 2015-03-16 19:34:00
P3 A 2015-03-16 19:58:00
P4 A 2015-03-16 21:02:00
P5 B 2015-03-16 21:18:00
P6 A 2015-03-16 21:19:00
P7 A 2015-03-16 21:33:00
P8 B 2015-03-16 21:35:00
P9 B 2015-03-16 23:43:00
I want to select independent pictures for each species (that is, pictures separated from each other by 1h), in this dataset with R.
In this example, for species A, I would only want to keep P1, P3 and P4. P2 wouldn't be considered because it falls within the 1h period that started with P1. P3 is considered since its DateTime (19h58) falls after 19h42. And now, the next 1h period would last until 20h58. For species B, only P5 and P9.
Therefore, after this filter, my dataset would look like this:
ID Species DateTime
P1 A 2015-03-16 18:42:00
P3 A 2015-03-16 19:58:00
P4 A 2015-03-16 21:02:00
P5 B 2015-03-16 21:18:00
P9 B 2015-03-16 23:43:00
Does someone know how to perform this in R?