I want to calculate percentage for a data frame which is like
day hour place t1 t2
___ ____ _____ __ ___
1 0 1 5 10
1 0 2 6 12
1 0 3 9 8
1 1 1 6 12
1 1 2 8 15
1 1 3 10 18
1 2 1 5 1
1 2 2 6 12
1 2 3 9 1
1 3 1 8 10
1 3 2 8 2
1 3 3 9 8
2 0 1 5 1
2 0 2 6 12
2 0 3 9 8
2 1 1 9 10
2 1 2 6 12
2 1 3 9 8
2 2 1 5 10
2 2 2 6 12
2 2 3 9 18
2 3 1 5 0
2 3 2 6 2
2 3 3 9 18
I want to calculate more two columns which will calculate the percentage of t1 and t2 by hour for example I want
day hour place t1 t2 t1% t2%
___ ____ _____ __ ___ ___ ___
1 0 1 5 10 (5/20) (10/30)
1 0 2 6 12 (6/20) (12/30)
1 0 3 9 18 (9/20) (18/30)
1 1 1 6 12 (12/24) (12/45)
1 1 2 8 15 (15/24) (15/45)
1 1 3 10 18 (18/24) (18/45)
That means the t1 divided by the sum of t1 for the day and hour of each places.I know to take sum for whole column but I want to take sum for each hour and day. Any help is appreciated.