我有相机陷阱数据,我想删除可能重复的动物检测。我将间隔设置为 60 分钟(1 小时),这样如果在不到 60 分钟的时间内再次检测到同一物种的任何个体,则该个体是同一个体。我的数据是在多个区块收集的,每个区块内有多个站点。
#Data example:
Block<-c("a","a","a","a","a","b","b","b","b","b") #2 block
Site<-c("p1","p1","p2","p2","p2","p1","p1","p1","p2","p2") #two sites
Species<-c("c","c","c","c","e","d","d","c","c","c")
datetime<-c("2021-03-29 05:45:00","2021-03-29 06:40:00","2021-03-30 05:45:00","2021-03-30 07:45:00","2021-03-29 09:45:00","2021-03-29 05:45:00","2021-03-29 05:55:00","2021-03-29 08:45:00","2021-03-29 10:45:00","2021-03-30 10:59:00")
df<-data.frame(Block, Site, Species, datetime)
#what I want for the output:
Block Site Species datetime
1 a p1 c 2021-03-29 05:45:00
2 a p2 c 2021-03-30 05:45:00
3 a p2 c 2021-03-30 07:45:00
4 a p2 e 2021-03-29 09:45:00
5 b p1 d 2021-03-29 05:45:00
6 b p1 c 2021-03-29 08:45:00
7 b p2 c 2021-03-29 10:45:00
8 b p2 c 2021-03-30 10:59:00
至少对我来说,棘手的部分是我需要删除在 1 小时内出现的 Block/Site/Species 的重复项(我不能只说保留一天中一小时内的第一个)。
感谢您的帮助。