【问题标题】:how to add time periods to get a total time period in R? [closed]如何添加时间段以获得 R 中的总时间段? [关闭]
【发布时间】:2017-08-12 02:56:53
【问题描述】:

如何计算一些时间段的总和?
例如,需要添加00:30:0000:10:0000:10:00 以获得50 分钟为00:50:00
怎么做?有sum这样的函数吗?

【问题讨论】:

  • 可能使用:library(lubridate); hms("00:30:00") + hms("00:10:00") + hms("00:10:00")

标签: r datetime time


【解决方案1】:

有几个选项,例如:

library(lubridate)
hms("00:30:00") + hms("00:10:00") + hms("00:10:00")

[1] "50M 0S"


library(chron)
x <- times(c("00:30:00", "00:10:00", "00:10:00"))
sum(x)
[1] 00:50:00

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-23
    • 2010-09-14
    • 2020-01-19
    • 2019-09-25
    • 2013-02-20
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多