简体   繁体   English

与R的时差。缺少日,月和年

[英]Time difference with R. When day, month and year absent

How to get date difference with R (in term of minutes) when day, month and year were not provided. 如果没有提供日期,月份和年份的R(以分钟为单位)的日期差异。

For instance minutes betweeen "23:14:01" and "00:02:01". 例如“23:14:01”和“00:02:01”之间的分钟。

You can use difftime : 你可以使用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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM