Reputation: 21
I have a series of decimal numbers (marathon race split times): 64.90, etc., and I want to convert it into HH:MM:SS format using R so that I can us the result to do time math. The answer I am looking for is: 1:04:54.
chron doesn't seem to be doing what I'm expecting it to do.
chron::times(64.90) Time in days: [1] 64.9
First time on this site, so be kind. Thanks.
Upvotes: 1
Views: 3371
Reputation: 269654
chron times are measured in days and since you apparently have minutes divide the input by the number of minutes in a day:
library(chron)
times(64.90 / (24 * 60))
## [1] 01:04:54
Upvotes: 3
Reputation: 47320
You could try lubridate::seconds_to_period
library(lubridate)
seconds_to_period(64.90)
[1] "1M 4.90000000000001S"
Upvotes: 2