I am having trouble subsetting data based on different attributes in different columns. Here is a dummy data set with species, area where it was found, and time (already in POSIXct).
SP Time Area
B 07:22 1
F 09:22 4
A 09:22 1
C 08:17 3
D 09:20 1
E 06:55 4
D 09:03 1
E 09:12 2
F 09:45 1
B 09:15 1
I need to subset the rows that have SP==A, plus all other species occurring in the same area (in this case 1), within a time window of +30 and -30 minutes returning this:
SP Time Area
A 09:22 1
D 09:20 1
D 09:03 1
F 09:45 1
B 09:15 1
I can't get past the conditional statement of this 1-hour window, should I use a for loop here, or is there a simpler way of subsetting this? Many thanks in advance.