How would I convert seconds into h/m/s format. I've tried to use seconds_to_period
but it only gives the value in seconds. e.g
ID Time
1 345 secs
2 121 secs
3 78 secs
I want this is in HH:MM:SS format how is this done?
How would I convert seconds into h/m/s format. I've tried to use seconds_to_period
but it only gives the value in seconds. e.g
ID Time
1 345 secs
2 121 secs
3 78 secs
I want this is in HH:MM:SS format how is this done?
We may use hms
from hms
after converting to period
library(lubridate)
df1$Time <- hms::hms(seconds_to_period(readr::parse_number(df1$Time)))
-output
> df1
ID Time
1 1 00:05:45
2 2 00:02:01
3 3 00:01:18
df1 <- structure(list(ID = 1:3, Time = c("345 secs", "121 secs", "78 secs"
)), class = "data.frame", row.names = c(NA, -3L))