我正在一个项目上,现在我有这个col,它记录一天中不同的时间点。我的数据集中有无数行。 这是我使用独特的功能给您一个想法之后得到的:
unique(cab_rides_filtered$time)
[1] 03:46:40 19:53:20 20:53:20 22:53:20 21:53:20 13:06:40 00:26:40 14:46:40 01:53:20 07:00:00
[11] 10:00:00 13:33:20 18:20:00 06:20:00 14:40:00 17:40:00 20:13:20 14:33:20 08:13:20 01:00:00
[21] 15:20:00 05:46:40 20:06:40 12:06:40 03:13:20 15:53:20 22:13:20 18:40:00 15:40:00 17:33:20
我使用
将列转换为时间格式 chron(times = cab_rides_filtered$time)
我想将一天中的24小时划分为8个日区,并将我现在拥有的所有这些时间点划分为一个称为日区的新列,例如,日区1是从00:00:00到02:59:59。
time day zone
03:46:40 2
dput(unique(cab_rides_filtered$time))
structure(c(0.157407407407407, 0.828703703703704, 0.87037037037037,
0.953703703703704, 0.912037037037037, 0.546296296296296, 0.0185185185185185,
0.615740740740741, 0.0787037037037037, 0.291666666666667, 0.416666666666667,
0.564814814814815, 0.763888888888889, 0.263888888888889, 0.611111111111111,
0.736111111111111, 0.842592592592593, 0.606481481481482, 0.342592592592593,
0.0416666666666667, 0.638888888888889, 0.240740740740741, 0.837962962962963,
0.50462962962963, 0.134259259259259, 0.662037037037037, 0.925925925925926,
0.777777777777778, 0.652777777777778, 0.731481481481482, 0.944444444444444,
0.5, 0.152777777777778, 0.99537037037037, 0.333333333333333,
0.305555555555556, 0.115740740740741, 0.217592592592593, 0.273148148148148,
0.810185185185185, 0.347222222222222, 0.175925925925926, 0.449074074074074,
0.365740740740741, 0.921296296296296, 0.490740740740741, 0.962962962962963,
0.796296296296296, 0.425925925925926, 0.148148148148148, 0.407407407407407,
0.0277777777777778, 0.300925925925926, 0.194444444444444, 0.532407407407407,
0.199074074074074, 0.143518518518519, 0.75462962962963, 0.0324074074074074,
0.768518518518518, 0.722222222222222, 0.537037037037037, 0.893518518518518,
0.680555555555556, 0.541666666666667, 0.226851851851852, 0.523148148148148,
0.773148148148148, 0.884259259259259, 0.37962962962963, 0.907407407407407,
0.037037037037037, 0.657407407407407, 0.0833333333333333, 0.847222222222222,
0.574074074074074, 0.587962962962963, 0.25, 0.259259259259259,
0.189814814814815, 0.578703703703704, 0.481481481481481, 0.00925925925925926,
0.314814814814815, 0.388888888888889, 0, 0.888888888888889, 0.712962962962963,
0.268518518518519, 0.125, 0.0694444444444444, 0.87962962962963,
0.805555555555556, 0.648148148148148, 0.851851851851852, 0.231481481481481,
0.310185185185185, 0.00462962962962963, 0.967592592592593, 0.49537037037037,
0.694444444444444, 0.356481481481481, 0.958333333333333, 0.597222222222222,
0.62037037037037, 0.111111111111111, 0.375, 0.472222222222222,
0.421296296296296, 0.0740740740740741, 0.0601851851851852, 0.726851851851852,
0.185185185185185, 0.462962962962963, 0.916666666666667, 0.430555555555556,
0.689814814814815, 0.384259259259259, 0.458333333333333, 0.791666666666667,
0.101851851851852, 0.12037037037037, 0.902777777777778), format = "h:m:s", class = "times")