0

我在包含小时的数据框中有一列,该列是通过将由分钟组成的另一列除以 60 而创建的,并希望将它们格式化为 hh:mm

我发现这篇文章很有帮助: Convert a decimal number to HH:MM:SS in R

但输出不正确,例如

   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

我在追

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

提前致谢。

4

1 回答 1

0

尝试这个:

> format(strptime(times(rd$Duration.h.mm / (24*60)),"%H:%M:%S"),'%M:%S')
[1] "01:56" "00:37" "02:14"
于 2020-04-22T09:46:16.220 回答