0

I have a column within a data frame containing hours that was created by dividing by 60 from another column that is comprised of minutes and would like them formatted to hh:mm

I found this post to be helpful: Convert a decimal number to HH:MM:SS in R

but the output is not correct for example

   Duration.h.mm
1   1.93
2   0.62
3   2.24
library(chron)

times(rd$Duration.h.mm / (24 *60))

## output :
   Duration.h.mm
1   00:01:56
2   00:00:37
3   00:02:14

I'm after

1 1:56 2 0:37 3 2:14

thanks in advance.

BigBird
  • 5
  • 3

1 Answers1

0

Try this:

> format(strptime(times(rd$Duration.h.mm / (24*60)),"%H:%M:%S"),'%M:%S')
[1] "01:56" "00:37" "02:14"
Mohanasundaram
  • 2,889
  • 1
  • 8
  • 18