如果没有提供日期,月份和年份的R(以分钟为单位)的日期差异。
例如" 23:14:01"和" 00:02:01"。
答案 0 :(得分:3)
您可以使用difftime
:
a <- strptime("23:14:01",format = "%H:%M:%S")
b <- strptime("00:02:01",format = "%H:%M:%S")
difftime(a,b, units = "mins")
# Time difference of 1392 mins
difftime_res_2 <- 1440 - difftime_res # In case the times are from following days
difftime_res_2
# Time difference of 48 mins