是否可以根据r中的时间变量过滤掉出与时间变量重叠的异常值?
如何使用filter()
检查ID列与日期/时间列之间的重叠来删除离群值?
例如,如下前2行所示,具有ID = 1的行的行重叠,因此需要删除。
ID | 时间开始 | 时间结束 |
---|---|---|
1 | 2015-03-16 10:40:00 | 2015-03-16 11:10:00 |
1 | 2015-03-16 10:50:00 | 2015-03-16 10:59:00 |
2 | 2015- 2015- 03-16 10:40:00 | 2015-03-16 10:45:00 |
1 | 2015-03-16 11:20:00 | 2015-03-16 11:28:56 |
How do I delete outliers by checking for an overlap between ID column and date/time columns withfilter()
?
For example, rows with ID =1 overlap in time as shown in the first 2 rows below,thus need to be deleted.
ID | Time start | Time end |
---|---|---|
1 | 2015-03-16 10:40:00 | 2015-03-16 11:10:00 |
1 | 2015-03-16 10:50:00 | 2015-03-16 10:59:00 |
2 | 2015-03-16 10:40:00 | 2015-03-16 10:45:00 |
1 | 2015-03-16 11:20:00 | 2015-03-16 11:28:56 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以删除组内的任何时间重叠。请使用更多数据对其进行测试,以查看是否执行您想要的工作。我只尝试了下面的小样本。
由
Try this to remove any time overlaps within a group. Please test it with more data to see if it does what you want. I only tried the small sample below.
Created on 2022-04-30 by the reprex package (v2.0.1)