1

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.

lounytoon
  • 21
  • 1
  • 3

3 Answers3

3

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
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341
2

You could try lubridate::seconds_to_period

library(lubridate)
seconds_to_period(64.90)
[1] "1M 4.90000000000001S"
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
2
library(hms)
as.hms(64.90*60)

output

01:04:54
vsb
  • 428
  • 6
  • 15