1

时间为整数格式,不带日期。我尝试使用包 lubridate,但它要求提供日期和时间。

我也无法在包 chron 中找到等效的 seq() 。

该列如下所示:

time
525
1526
756
2252
...

525 代表 5:25;1526 代表 7:56。而且我想要一个表格来计算每 15 分钟间隔的频率;间隔是00:00-00:15, 00:16-00:30, 00:31-00:45, 00:46-00:59, ..., 23:46-23:59

4

1 回答 1

0

我们可以转换为ITimewith as.ITimefromdata.table

library(data.table)
v2 <- as.ITime(sub("^(..)", "\\1:", sprintf('%04d:00', df1$time)))
table(cut(v2, breaks = 15))

数据

df1 <- structure(list(time = c(525, 1526, 756, 2252)), class = "data.frame", row.names = c(NA, 
-4L))
于 2020-03-13T00:49:09.177 回答