I am trying to analyze real-world Google traces for my research. I have the arrival time of tasks in milliseconds and I would like to represent in y-axis -> avg. number of tasks per hour vs. x-axis -> hour of day. I am struggling so far. I put only 2000 values of arrival time for simplicity. Any help would be really appreciate.
Python code to translate to R:
one_hour_in_milliseconds = 1000*60*60
hours_in_a_day = 24
def get_tasks_per_hour_of_day(tasks_df):
tasks_per_hour_df = tasks_df.groupby(F.floor(F.col("ts_submit") / F.lit(one_hour_in_milliseconds)).alias("hour")).count()
tasks_per_hour_of_week = tasks_per_hour_df.groupby((F.col("hour") % hours_in_a_day).alias("hour_of_day")).agg(F.avg("count"))
return tasks_per_hour_of_week
"ts_submit" correspond to the arrival time and it is like this:
arrival_time <- c(757956, 757956, 757956, 760949, 760949, 760949, 760949, 760949,
760949, 760949, 760950, 760950, 760950, 760950, 760950, 760950,
772013, 870116, 870116, 870116, 870117, 870117, 870117, 870118,
870118, 919618, 1107986, 1372983, 1372983, 1372983, 1372984,
1372984, 1398938, 1398938, 1398938, 1398939, 1423337, 1423337,
1423337, 1423337, 1423337, 1423338, 1423338, 1423338, 1423339,
1423339, 1437049, 1437049, 1437049, 1437050, 1437050, 1437050,
1437050, 1437050, 1437051, 1437051, 1437051, 1437051, 1599232,
1599232, 1599232, 2073894, 2100114, 2100114, 2100114, 2100114,
2100114, 2100115, 2112582, 2122978, 2135463, 2135463, 2135464,
2135464, 2135464, 2135464, 2135464, 2135466, 2135466, 2140221,
2149856, 2149857, 2149857, 2175430, 2175431, 2175431, 2175431,
2175431, 2175432, 2175432, 2175432, 2199343, 2199343, 2199343,
2199344, 2199344, 2199345, 2199345, 2199345, 2199346, 2488835,
2639241, 2639241, 2639241, 2639241, 2639241, 2639242, 2639242,
2639242, 2639242, 2788104, 2788104, 2788104, 2788105, 2788105,
2851444, 2851444, 2851444, 2851444, 2851445, 2851445, 2851445,
2851445, 2851445, 3094321, 3094321, 3094321, 3238164, 3238164,
3238164, 3238165, 3238165, 3238165, 3238165, 3410843, 3410843,
3413803, 3525977, 3525978, 3525978, 3525978, 3525978, 3525978,
3549873, 3549873, 3549873, 3549873, 3549873, 3549873, 3549873,
3549873, 3549873, 3851600, 3851601, 3938009, 3938009, 3938009,
3986760, 4037632, 4186660, 4186660, 4186660, 4186660, 4205532,
4205532, 4223089, 4223090, 4223090, 4223090, 4277981, 4277981,
4314340, 4314340, 4365067, 4365067, 4365068, 4365068, 4365068,
4365068, 4365068, 4365068, 4365068, 4365068, 4365068, 4607608,
4839388, 4839388, 4852011, 4852011, 4852011, 4852011, 4852011,
4852011, 4948953, 4948954, 4948954, 4950308, 4950308, 4950309,
4950309, 4950309, 5269837, 5286999, 5334312, 5475300, 5548613,
5797195, 5797195, 5797196, 5797196, 6003342, 6144761, 6144761,
6209245, 6232036, 6385718, 6497910, 6675175, 6675175, 6726517,
6751350, 6751350, 6751350, 6751351, 7146772, 7561379, 7625130,
7879679, 8109251, 8183407, 8183407, 8183407, 8183408, 8183408,
8291747, 8341073, 8341910, 8341911, 8341911, 8341912, 8341912,
8341912, 8341912, 8341912, 8341913, 8341913, 8341913, 8341914,
8341914, 8559979, 8559979, 8559979, 8597532, 8597532, 8736044,
8736044, 8847283, 8847283, 8847283, 8847283, 8886313, 8886313,
8923410, 9386029, 9386030, 9386030, 9683967, 10109483, 10125754,
10154979, 10190049, 10214849, 10288755, 10298767, 10698932, 10698933,
10698933, 10911758, 10937271, 10937271, 11408067, 11408067, 12213612,
12311840, 12311840, 12311840, 12311840, 12472906, 12509542, 12509542,
12911217, 12911226, 13163002, 13163002, 13163002, 13185420, 13185420,
13185420, 13185421, 13185421, 13185421, 13185421, 13252574, 13374280,
13398830, 13398830, 13400736, 13475167, 13475168, 13475169, 13701338,
13701339, 13701339, 13701339, 13701339, 13701339, 13701340, 13701340,
13701340, 13701340, 13701340, 13701340, 13826250, 13826250, 13826250,
13954187, 13954187, 13954187, 13954188, 13962612, 14072634, 14294046,
14294047, 14294047, 14294047, 14294047, 14294048, 14294048, 14294048,
14294049, 14294049, 14294049, 14364720, 14364720, 14364720, 14364720,
14663840, 14874149, 14874149, 14874149, 14874149, 14937730, 15314089,
15326106, 15326108, 15326108, 15326108, 15326108, 15326108, 15326109,
15326109, 15326109, 15326110, 15326110, 15326110, 15326111, 15326111,
15338576, 15486616, 15486616, 15647460, 15647460, 15647460, 15647460,
15806441, 15806441, 15844483, 15844483, 15844483, 15844483, 15844483,
15844483, 15844483, 15844483, 15918805, 15918805, 15986737, 15986738,
15986738, 15986738, 15986739, 15986740, 16079743, 16216549, 16216549,
16216549, 16216549, 16254921, 16254921, 16254921, 16254922, 16254922,
16254922, 16254922, 16254922, 16254923, 16254923, 16469030, 16530256,
16530257, 16617988, 16801458, 16907652, 17301184, 17301185, 17301186,
17301186, 17458282, 17458283, 17458283, 17458284, 17494866, 17507368,
17507368, 17583714, 17583714, 17921147, 18069403, 18069404, 18069404,
18094921, 18094921, 18244693, 18244693, 18244693, 18244693, 18244693,
18391425, 18472661, 18472661, 18708037, 18708037, 18797563, 18821442,
18844215, 18981864, 18981864, 18981864, 19007073, 19009142, 19084466,
19084466, 19084466, 19109977, 19198215, 19198215, 19198216, 19348976,
19410777, 19410777, 19410777, 19549339, 19582661, 19660325, 19709086,
19758327, 19821920, 19909761, 19909761, 20080135, 20080135, 20080135,
20080135, 20143181, 20296794, 20485668, 20485668, 20485668, 20485668,
20485668, 20485669, 20485669, 20485669, 20522133, 20524785, 20524785,
20538764, 20538764, 20787352, 20834431, 21135456, 21135456, 21268106,
21268106, 21307519, 21695402, 21695402, 21695402, 21695402, 21695402,
21695402, 21695403, 21695403, 21695403, 21700449, 21708509, 21708509,
21846639, 21869462, 21869463, 21869463, 21911309, 21911309, 22113517,
22113518, 22113518, 22132507, 22175044, 22175044, 22175044, 22175044,
22175044, 22175045, 22175045, 22224907, 22274211, 22291331, 22349386,
22349386, 22349388, 22349388, 22452173, 22464686, 22464686, 22464687,
22502278, 22571928, 22571928, 22588242, 22714864, 22866236, 23227341,
23227341, 23250030, 23251797, 23265533, 23298161, 23353828, 23353828,
23353829, 23353829, 23353829, 23363507, 23363507, 23456219, 23467556,
23528672, 23528672, 23528672, 23528673, 23595173, 23605403, 23605403,
23664892, 23689971, 23804575, 24039832, 24095776, 24095776, 24095776,
24095776, 24095776, 24095776, 24095776, 24095776, 24095776, 24095777,
24104204, 24115500, 24119849, 24120916, 24352267, 24352267, 24352267,
24442081, 24670784, 24705243, 24705243, 24724065, 24864393, 24949334,
25007713, 25007713, 25010975, 25110349, 25187708, 25187708, 25498002,
25667013, 25667013, 25667013, 25667014, 25699719, 25707399, 25740850,
26043560, 26064571, 26064571, 26136232, 26136233, 26136233, 26136234,
26136234, 26150821, 26230497, 26259966, 26291610, 26291610, 26644150,
26644150, 26644150, 26644150, 26785031, 26785032, 26785042, 26785042,
26785042, 26785042, 26785042, 26785043, 26785043, 26842512, 26842512,
26920823, 27083447, 27083448, 27083448, 27083449, 27083449, 27083449,
27083450, 27083450, 27083450, 27083450, 27083450, 27083534, 27083534,
27083534, 27083534, 27083535, 27083536, 27083536, 27083537, 27179751,
27204895, 27514060, 27681148, 27755972, 27755980, 27755986, 27758456,
28093450, 28093450, 28093450, 28142347, 28210772, 28363317, 28363317,
28497902, 28497902, 28497902, 28497902, 28497903, 28497903, 28497903,
28497904, 28497904, 28497904, 28497904, 28497904, 28497904, 28497904,
28497904, 28497904, 28497905, 28497905, 28497905, 28497905, 28497905,
28546659, 28546660, 28546660, 28546660, 28546660, 28546661, 28546661,
28551688, 28551688, 28551688, 28551689, 28551689, 29248859, 29248859,
29248859, 29309935, 29535662, 29535662, 29541149, 29707778, 29848098,
29848098, 29983569, 29983569, 29983569, 29983569, 29983570, 29983570,
30194883, 30442041, 30442041, 30442041, 30525968, 30525969, 30604622,
30823608, 30885528, 31159416, 31345499, 32354843, 32354844, 32354844,
32354844, 32354845, 32354845, 32354845, 32354846, 32354846, 32354846,
32354846, 32354846, 32443597, 32443597, 32443597, 32443597, 32443597,
32443598, 32443598, 32443598, 32443598, 32443599, 32443599, 32443599,
32443600, 32443600, 32443600, 32443601, 32443601, 32443603, 32443603,
32443604, 32443604, 32443605, 32443605, 32443606, 32443607, 32443608,
32443608, 32443609, 32443609, 32443609, 32443610, 32443610, 32443611,
32443611, 32443612, 32443613, 32443613, 32443613, 32443613, 32443614,
32443615, 32443616, 32443617, 32443617, 32443617, 32491340, 32493301,
32951556, 33037800, 33098521, 33235764, 34113105, 34336104, 34409634,
34418071, 34418071, 34418071, 34418071, 34418072, 34418072, 34418072,
34418073, 34418073, 34418074, 34418074, 34418074, 34418074, 34637093,
34637093, 34637093, 34637094, 34637094, 34761083, 34905880, 34979175,
34979175, 35016369, 35016370, 35016370, 35016371, 35016371, 35016371,
35019674, 35019674, 35166054, 35850468, 35859368, 36014996, 36317663,
36317663, 36317663, 36317664, 36317665, 36317666, 36317666, 36863673,
36863674, 36929379, 37088849, 37279075, 37309596, 37309596, 37309597,
37504453, 37528551, 37530874, 37530874, 37530875, 37530875, 37530876,
37530876, 37614185, 37667591, 37702858, 37704580, 37704580, 37714912,
37855804, 38189537, 38213184, 38308386, 38308386, 38308386, 38308387,
38308387, 38308387, 38308387, 38308387, 38308387, 38308387, 38308387,
38308387, 38308388, 38308388, 38308388, 38308388, 38308389, 38308389,
38308389, 38308389, 38308389, 38308390, 38308390, 38308390, 38308391,
38308391, 38308391, 38308392, 38308392, 38308392, 38308392, 38308392,
38308393, 38308393, 38308393, 38308394, 38308394, 38308395, 38308395,
38308395, 38308395, 38308396, 38308396, 38308396, 38308396, 38308396,
38430415, 39140178, 39140178, 39140179, 39140179, 39140179, 39415380,
39575481, 39575481, 39575481, 39575481, 39575482, 39575482, 39575483,
39575483, 39575483, 39575483, 39583572, 39670699, 39670699, 39913944,
39919941, 39941344, 39941344, 39941344, 39941344, 39941345, 39941345,
39941345, 39941345, 39941345, 40200753, 40699497, 40699497, 41230877,
41230877, 41230878, 41230878, 41312702, 41423823, 42135444, 42135444,
42135460, 42148090, 42148150, 42148162, 42148162, 42212294, 42390686,
42390686, 42390687, 42390687, 42390687, 42390688, 42390689, 42390690,
42635231, 42635231, 42638029, 42638029, 42638029, 42980989, 43344928,
43485736, 44401393, 44542352, 44542352, 44736757, 44736757, 44736757,
44736757, 44772454, 44774029, 44774030, 44808621, 44915963, 45212960,
45637062, 45637062, 45637062, 45637062, 45637062, 45776584, 46184655,
46357726, 46357726, 46357726, 46357727, 46657424, 46657425, 46657425,
46657425, 46657425, 46657425, 46657425, 46657425, 46657426, 46657426,
46657426, 46657426, 46657426, 46657426, 47360778, 47433852, 47433852,
47433852, 47433984, 47433985, 47604913, 47662504, 47662504, 47662505,
47662505, 47662505, 47662505, 47662505, 47662506, 47662506, 47814440,
47814440, 47814440, 47849206, 47849207, 47849207, 47849207, 47849208,
47861403, 47861403, 47861403, 47861403, 47861403, 47861404, 47861404,
47861404, 47861404, 47861404, 47861405, 47861405, 47861405, 47861405,
47861406, 47861406, 47861406, 47861407, 47861407, 47861407, 47861407,
47861408, 48463583, 48469546, 48524758, 48661693, 48673536, 48673536,
48673536, 48673537, 48689005, 48699797, 48699798, 48699798, 48699799,
48699799, 48699800, 48699800, 48699801, 48699801, 48699802, 48699802,
48723653, 48723653, 48723653, 49037695, 49037699, 49163896, 49189852,
49189852, 49286549, 49286549, 49297165, 49325507, 49334090, 49337118,
49749268, 49749269, 49758997, 49800456, 49800456, 49800456, 49800457,
49800457, 49800457, 49800457, 49800457, 49800457, 49800457, 49800458,
49800458, 49800458, 49800458, 50114159, 50265451, 50469956, 50482424,
50482424, 50482424, 50482424, 50482424, 50482424, 50482425, 50482425,
50482425, 50482425, 50482426, 50482426, 50482426, 50482426, 50482427,
50482427, 50482427, 50482427, 50482427, 50482427, 50482428, 50482428,
50482428, 50482428, 50482429, 50482429, 50482429, 50482429, 50482429,
50482431, 50482431, 50482431, 50482431, 50482431, 50482431, 50482432,
50482432, 50482433, 50482433, 50482433, 50482433, 50482433, 50482433,
50482434, 50636008, 50636008, 50639808, 50639809, 50639809, 50639809,
50639810, 50680249, 51425487, 51568769, 51582475, 51855743, 52094367,
52406956, 52406956, 52481978, 52550437, 52560092, 52560092, 52754531,
53021992, 53021992, 53021992, 53021993, 53021993, 53021994, 53021994,
53021994, 53021995, 53021995, 53037426, 53037427, 53037427, 53060227,
53281608, 53281608, 53281608, 53307653, 53355669, 53355669, 53647271,
53647272, 53709981, 53709982, 53720672, 53720690, 53795612, 53795612,
53795613, 53795613, 53795613, 53795615, 53795615, 53795616, 53795616,
53795616, 53795618, 53795618, 53795619, 53795619, 53795619, 53925439,
54010507, 54537694, 54637861, 54738366, 54845159, 54873097, 54892639,
54950924, 54979981, 54979981, 54979981, 55107460, 55390353, 55390353,
55390353, 55390353, 55390353, 55390354, 55390354, 55390354, 55390354,
55390354, 55545710, 55545710, 55560762, 55560763, 55571473, 55571473,
55571474, 55574240, 55574241, 55574241, 55574241, 55574241, 55574241,
55574241, 55574241, 55638292, 55668469, 55832897, 55860912, 55860913,
55860913, 55860914, 55860914, 55887756, 56198611, 56198612, 56198612,
56198612, 56198612, 56198613, 56198613, 56198613, 56494310, 56494310,
56517633, 56517633, 56517633, 56517642, 56519945, 56530111, 56530112,
56793944, 56793944, 56793944, 56793944, 56893498, 56897176, 57142484,
57253989, 57329324, 57369776, 57369776, 57369776, 57369776, 57889818,
57889818, 57889818, 57889819, 57889819, 57889819, 57889819, 57891918,
57891919, 57891919, 57891919, 57961257, 58176575, 58176575, 58176576,
58176576, 58176576, 58176577, 58176577, 58377258, 58377258, 58377259,
58377259, 58377260, 58443163, 58627503, 58741438, 58931876, 59079448,
59079448, 59079448, 59079448, 59079449, 59079449, 59079450, 59079450,
59079451, 59084904, 59084905, 59112957, 59129501, 59129501, 59129501,
59129501, 59129501, 59129502, 59129502, 59176863, 59225796, 59225796,
59268481, 59268481, 59371229, 59371230, 59439688, 59447236, 59447236,
59447236, 59447237, 59447237, 59447238, 59683626, 59940114, 60325859,
60411051, 60634569, 60634569, 60729839, 60824385, 60829336, 60988482,
61011801, 61011801, 61090753, 61205430, 61245545, 61336568, 61657853,
61657853, 61657854, 61657854, 61657855, 61657855, 61657855, 61682564,
61685227, 61912488, 61912488, 61912488, 62012104, 62012104, 62012104,
62012105, 62058074, 62058919, 62513624, 62528305, 62575355, 62671367,
62694310, 62806735, 62806735, 62871168, 62885177, 62885179, 62886202,
62886202, 62886202, 62886203, 62886204, 62886204, 62886205, 62886205,
62933437, 63125213, 63171350, 63171350, 63214146, 63214146, 63262433,
63360290, 63444920, 63447598, 63546986, 63751354, 63787894, 63787895,
63833676, 63981489, 63981489, 63997975, 64384806, 64522143, 64522143,
64522143, 64522143, 64522144, 64536594, 64536594, 64660657, 64796620,
64796620, 64796620, 64999801, 65233922, 65267983, 65267983, 65405554,
65539371, 65625725, 65704385, 65760736, 66161330, 66316074, 66364353,
66364353, 66364353, 66466991, 66488145, 66488145, 66506952, 66506953,
66579607, 66740301, 66740302, 66740302, 66740302, 66740302, 66740302,
66740303, 66740303, 66820009, 67091236, 67091236, 67091236, 67113527,
67151838, 67248954, 67248955, 67248955, 67248955, 67248955, 67408976,
67573552, 67573552, 67666935, 67881803, 67916236, 67971425, 68246431,
68471507, 68495414, 68780188, 68837867, 69068470, 69068470, 69068470,
69068470, 69068471, 69068472, 69068472, 69068472, 69068473, 69068473,
69273410, 69273410, 69478571, 69545443, 69545444, 69545444, 69907898,
70189600, 70189601, 70718202, 70724278, 70724278, 70796341, 70796341,
70826560, 70857008, 70862056, 70863680, 70863681, 70863681, 70943370,
71004502, 71004503, 71053539, 71059974, 71059974, 71075017, 71079823,
71097524, 71100997, 71100997, 71100997, 71134237, 71134237, 71134237,
71134238, 71134238, 71134238, 71134238, 71134238, 71134238, 71134238,
71134238, 71134239, 71134239, 71134239, 71134239, 71134239, 71134239,
71290708, 71290708, 71290708, 71329874, 71329874, 71370725, 71370725,
71370725, 71370725, 71370726, 71370726, 71469848, 71469848, 71539790,
71539790, 71563614, 71622432, 71806530, 71806530, 71806531, 72135750,
72178223, 72178223, 72274414, 72351729, 72675060, 72675061, 72675061,
72675061, 72675061, 72675062, 72675062, 72675062, 72675062, 72675063,
72675063, 72675063, 72675063, 72675063, 72675063, 72777183, 72777183,
72777183, 72777184, 72777184, 72777184, 72777185, 72777186, 72777186,
72780189, 72780189, 72780189, 72780189, 72780190, 72780190, 72780190,
72780190, 72788659, 72796723, 72978870, 73207448, 73401342, 73522703,
73522703, 73566900, 73566901, 73566901, 73566901, 73572839, 73585497,
73585497, 73585498, 73585619, 73585619, 73683372, 73735106, 73755927,
73755927, 73755928, 73762112, 73833778, 73833778, 74026418, 74029109,
74060244, 74097558, 74143707, 74143707, 74143707, 74143707, 74143708,
74143708, 74143708, 74143720, 74143721, 74143721, 74143721, 74143722,
74143722, 74143723, 74143723, 74143723, 74143724, 74163648, 74163648,
74163648, 74163649, 74163650, 74163650, 74163650, 74163650, 74163650,
74163651, 74163651, 74225586, 74229234, 74229234, 74244927, 74244927,
74267674, 74267674, 74468446, 74529190, 74546378, 74550484, 74608548,
74680812, 74680812, 74680812, 74680813, 74680813, 74680813, 74680814,
74722815, 74872271, 74895622, 74895623, 74952896, 75123194, 75123194,
75287349, 75396027, 75396027, 75396028, 75396028, 75694684, 75697179,
75788767, 75806456, 76004572, 76175984, 76178539, 76178540, 76665433,
76789974, 76789974, 76789975, 76789975, 76984916, 77088158, 77088158,
77211792, 77220562, 77269965, 77398749, 77398749, 77460675, 77553760,
77737735, 77773127, 77848104, 78098123, 78186359, 78278050, 78278050,
78278050, 78292132, 78315016, 78361410, 78361410, 78361410, 78361448,
78361448, 78361448, 78385967, 78385967, 78385967, 78385968, 78410826,
78510022, 78531930, 78535277, 78535277, 78572226, 78611469, 78639538,
78657266, 78688108, 78787315, 78787315, 78857986, 78857986, 78894564,
78894564, 79051278, 79070637, 79174030, 79246177, 79350675, 79406571,
79639643, 79639643, 79639643, 79707252, 79746611, 79985433, 79985436,
79985436, 80008991, 80041214, 80085547, 80144783, 80311060, 80491693,
80491693, 80491693, 80491693, 80491694, 80505779, 80559619, 80644479,
80880743, 80880744, 80920419, 80920419, 80920420, 81018404, 81022920,
81110021, 81152159, 81152160, 81154987, 81154988, 81154988, 81196294,
81201358, 81201358, 81201358, 81204946, 81305550, 81347707, 81347708,
81347708, 81434323, 81898669, 81898669, 81898669, 81898669, 81898669,
81979010, 82174601, 82174601, 82174601, 82174601, 82174602, 82174602,
82174602, 82174602, 82174602, 82174602, 82174602, 82174602, 82249955,
82296355, 82320090, 82520048, 82747607, 82747607, 82819990, 82819990,
82851264, 82873136, 82873136, 82873136, 82873136, 82873137, 82873138,
82993012, 83207843, 83285153, 83288998, 83288998, 83288998, 83288998,
83294190, 83294190, 83294191, 83371710, 83822767, 83915529, 84075828,
84075829, 84075829, 84075829, 84075830, 84228502, 84228503, 84331280,
84429542, 84429542, 84475188, 84538851, 84590030, 84590030, 84590031,
84662177, 84697070, 84943765, 85039997, 85047461, 85047461, 85047462,
85076835, 85125425, 85125426, 85125426, 85125426, 85166777, 85166777,
85186810, 85221710, 85314545, 85317218, 85352519, 85352519, 85352521,
85352521, 85352522, 85352522, 85392206, 85392206, 85392206, 85392207,
85392207, 85392207, 85392207, 85392207, 85392208, 85392208, 85392208,
85392208, 85392209, 85392209, 85392209, 85392210, 85398185, 85398185,
85398186, 85398186, 85398187, 85398187, 85398187, 85426511, 85426511,
85426511, 85426513, 85426513, 85426514, 85426514, 85426514, 85426514,
85466060, 85466060, 85466060, 85466060, 85466060, 85466061, 85466061,
85612637, 85630078, 85630078, 85630079, 85758504, 85758504, 85758504,
85758504, 85758504, 85758505, 85865854, 85865854, 85865854, 85869891,
85869891, 85869891, 85869891, 85869891, 85869892, 85869892, 85869892,
85869892, 85869892, 85869893, 85969662, 86022326, 86022327, 86022327,
86022327, 86022327, 86022327, 86022327, 86022327, 86022327, 86045129,
86062688, 86062688, 86062688, 86062689, 86062689, 86062689, 86062689,
86062689, 86062689, 86062689, 86062689, 86207257, 86365835, 86365835,
86365835, 86365835, 86365836, 86365837, 86365837, 86365837, 86365837,
86365838, 86365838, 86707487, 86867203, 86867204, 86867204, 86867204,
86867204, 86886456, 87008520, 87008520, 87082425, 87082425, 87082425,
87082425, 87082426, 87082426, 87082426, 87082426, 87082427, 87082427,
87342981, 87342981)
The desired output should be like this for Google:
CodePudding user response:
Uploading two approaches here:
First, converting the list to data frame:
arrival_time <- data.frame(arrival_time)
If you want to get the exact hour of the day, in that case, the number of observations per distinct hour will be very less and the plot will be a bit congested:
library(ggplot2)
arrival_time %>%
mutate(hour = (arrival_time/(1000*60*60))) %>%
group_by(hour) %>%
summarise(count=n()) %>%
ggplot()
geom_point(aes(x=hour, y=count))
geom_line(aes(x=hour, y=count, group=1))
xlab('Hour of day')
ylab('Avg. num. tasks per hour')
theme_bw()
Now if you consider the arrival as I mentioned in the comment, that is, if the arrival is between 0 to 15 mins, it will be considered as hour 0. If it is between 1 hr 1 min and 2 hour, it will be considered as hour 1 and like this:
arrival_time %>%
mutate(hour = floor(arrival_time/(1000*60*60))) %>%
group_by(hour) %>%
summarise(count=n()) %>%
ggplot()
geom_point(aes(x=hour, y=count))
geom_line(aes(x=hour, y=count))
xlab('Hour of day')
ylab('Avg. num. tasks per hour')
theme_bw()
This is something similar to what you want from the plot you've shared in the question. Though the logic from the comment doesn't match.
Adding another plot as asked in the comment.
arrival_time %>%
mutate(hour = floor(arrival_time/(1000*60*60)),
minute= floor(arrival_time/(1000*60))) %>%
group_by(hour, minute) %>%
summarise(count=n()) %>%
ungroup() %>%
ggplot()
geom_point(aes(x=minute, y=count))
geom_line(aes(x=minute, y=count))
scale_x_continuous(breaks = seq(0, 1440, 60), labels = seq(0, 24, 1))
xlab('Hour of day')
ylab('Avg. num. tasks per hour')
theme_bw()