In R, use lubridate to convert hms objects into seconds

后端 未结 2 739
你的背包
你的背包 2021-02-15 03:04

simple question in lubridate--I want to convert an hms object into its appropriate number of seconds since the start of the day.

For instance

library(lub         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-15 03:54

    R>lubridate::period_to_seconds(hms("01:00:00")) 
    

    gives expected 3600 seconds as numeric counting from 00:00:00 or in the case above:

    R>period_to_seconds(hms("12:34:45")) 
    

提交回复
热议问题