I have a time series basis. In the base it has information of consumption of ration of pigs (it follows below with information of only one day and one animal). There is a column with the identification of the animal, day and time of day that the animal consumed the feed. In the hour column I needed 0 to 23, and in the hours the animal did not consume it would be zero consumption. After that I need to calculate the total consumption every six hours within each day. In other words, in the final table would only have the total consumption of 0 to 5, 6 to 11, 12 to 17 and 18 to 23 o'clock.
X Animal Dia Hora Consumo
1 1 5 1 1 89.96
2 2 5 1 1 44.98
3 3 5 1 1 74.97
4 4 5 1 2 134.95
5 5 5 1 2 14.99
6 6 5 1 2 59.98
7 7 5 1 9 419.83
8 8 5 1 9 59.98
9 9 5 1 9 74.97
10 10 5 1 9 29.99
11 11 5 1 11 29.99
12 12 5 1 11 194.92
13 13 5 1 13 119.95
14 14 5 1 13 29.99
15 15 5 1 14 59.98
16 16 5 1 16 254.90
17 17 5 1 18 179.93