La fonction as.period(), du package lubridate, permet de convertir un intervalle en periode selon différentes unités.

 


library(lubridate)   span <- new_interval(as.POSIXct("2009-01-01"), as.POSIXct("2010-02-02 01:01:01")) #On crée un nouvel intervalle span [1] 2009-01-01 CET--2010-02-02 01:01:01 CET   as.period(span, unit = "years") [1] "1y 1m 1d 1H 1M 1S"   as.period(span, units = "month") [1] "13m 1d 1H 1M 1S"   as.period(span, units = "day") [1] "397d 1H 1M 1S"

as.period(span, units = "second")
[1] "34304461S"