特定事件之间的时间计算 [英] Time Calculation Between Specific Events

查看:78
本文介绍了特定事件之间的时间计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的数据的子集:

Fr         Sig  Code NumDet    Date.Time          Aerial
62  150102 102   15    195 2012-09-14 18:28:00      1
63  150102 102   15    189 2012-09-14 18:32:00      1
64  150102 106   15    213 2012-09-14 18:36:00      1
65  150102 102   15    152 2012-09-14 18:40:00      1
66  150102 105   15    190 2012-09-14 18:46:00      1
67  150102  97   15      4 2012-09-14 18:51:00      2

我正在尝试计算两次第一次之间的时间在天线1上进行检测,然后在天线2上进行首次检测。因此,在此数据集中应该是23分钟

I am trying to calculate time between first detection on Aerial 1 and first detection on Aerial 2. Hence in this data set it would be 23mins

我尝试了 difftime ,但似乎无法根据天线编号选择特定时间。

I have tried variations of difftime but can't seem to select specific times based on the Aerial number.

我尝试过:

a <- difftime(table$Date.Time[2:length(table$Aerial == "1")], 
              table$Date.Time[2:length(table$Aerial == "2")])

,但还没到。

推荐答案

此命令使用 difftime

difftime(table$Date.Time[table$Aerial == "2"][1],
         table$Date.Time[table$Aerial == "1"][1])

将返回

Time difference of 23 mins

这篇关于特定事件之间的时间计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆