I have a list of marked individuals (column Mark) which have been captured various years (column Year) within a range of the river (LocStart and LocEnd). Location on the river is in meters.
I would like to know if a marked individual has used overlapping range between years i.e. if the individual has gone to the same segment of the river from year to year.
Here is an example of the original data set:
ID
Mark
Year
LocStart
LocEnd
11081
1992
21,729
22,229
21081
1992
21,203
21,703
31081
2005
21,508
22,008
41126
1994
19,222
19,522
51126
1994
18,811
19,311
61283
2005
21,754
22,254
71283
2007
22,025
22,525
Here is what I would like the final answer to look like:
Mark
Year1
Year2
IDs
10811992
2005
1, 3
10811992
2005
2, 3
12832005
2007
6, 7
In this case, individual 1126 would not be in the final output as the only two ranges available were the same year. I realize it would be easy to remove all the records where Year1 = Year2.
I would like to do this in R and have looked into the >IRanges package but have not been able to consider the group = Mark and been able to extract the Year1 and Year2 information.