How to calculate mean of period
in lubridate
?
library(lubridate)
# tibble
tbl <- tibble(time_1 = ymd_hms(c("2021-01-01 12:00:00"), ("2021-01-01 12:12:36"), ("2021-01-01 14:25:45")),
time_2 = ymd_hms(c("2021-01-01 12:12:36"), ("2021-01-01 14:25:45"), ("2021-01-01 15:35:45")),
time_period = seconds_to_period(difftime(time_2, time_1, units = 'sec')))
# calculate mean of period (WRONG ANSWER)
tbl %>% summarise(mean_val = mean(time_period))