Is there a Time-only R class?

后端 未结 2 376
遥遥无期
遥遥无期 2021-01-07 14:00

Is there a way to store time data in R in a class that only handles time (without dates)? I don\'t need to include dates and I feel it will take up extra memory and visualiz

相关标签:
2条回答
  • 2021-01-07 14:34

    As my previous comment, here an example of period class from the lubridate package, which I think it might be useful for you. For more information just ?Period-class.

    library(lubridate)
    t1 <- hm("10:38") 
    t1
    [1] "10H 38M 0S"
    t2 <-  hm("10:39")
    t1 - t2
    [1] "-1M 0S"
    
    0 讨论(0)
  • 2021-01-07 14:43

    Package data.table has a new class ITime which solves this problem ideally.

    library(data.table)
    > as.ITime("12:00")-as.ITime("11:10:01")
    [1] "00:49:59"
    
    0 讨论(0)
提交回复
热议问题