我有以下data.table,我想计算两个特定行(1和4)之间的时差,然后将计算值添加到新列。原表:
Name Type
Main processing time 2015-12-26 13:36:40
AA AA data
bb bb data
End processing Time 2015-12-26 14:36:40
最终结果
Name Type
Main processing time 2015-12-26 13:36:40
AA AA data
bb bb data
End processing Time 2015-12-26 14:36:40
Total time 1 hour
数据:
dt <- structure(list(
Name = c("Main processing time", "AA", "bb", "End processing Time"),
Type = c("2015-12-26 13:36:40", "AA data", "bb data", "2015-12-26
14:36:40")),.Names = c("Name", "Type"), row.names = 1:4, class =
"data.table")
有关如何使用data.table执行此操作的任何建议?我只能找到连续行的其他解决方案。非常感谢任何帮助!