0

I have this vector:

numbers <- c(2.4, 0.7, 0.5, 0.2, 0.9, 0.6)

How, using lubridate, can I convert these decimal numbers to times (hours:mins:secs). So the output should be the following vector of class Period

(02:24:00, 00:42:00, 00:30:00, 00:12:00, 00:54:00, 00:36:00)

I have searched both stack overflow and the Google for an answer to this question. It might be that I'm using the wrong search terms, but I cannot find an answer.

luciano
  • 13,158
  • 36
  • 90
  • 130
  • Trim the unit and convert the decimal. –  Feb 16 '16 at 10:50
  • 1
    Try `format(as.POSIXct("2016-02-16 00:00:00") + 3600*numbers, '%H:%M:%S')` (as the dupe link gives only a partial answer) – akrun Feb 16 '16 at 10:52

0 Answers0