Okay so I have a dataframe like this:
ID Month Year DOW Value
1 Jan 2019 Fri 20
1 Jan 2019 Sat 39
1 Feb 2019 Fri 30
1 Feb 2019 Sat 24
2 Jan 2019 Fri 20
2 Jan 2019 Sat 12
2 Feb 2019 Fri 1
2 Feb 2019 Sat 3
My goal is to determine the percent of each row in reference to the Month Year;
Manually calculating this the answer should be:
ID Month Year DOW Value Percent
1 Jan 2019 Fri 20 .338
1 Jan 2019 Sat 39 .661
1 Feb 2019 Fri 30 .554
1 Feb 2019 Sat 24 .444
2 Jan 2019 Fri 20 .625
2 Jan 2019 Sat 12 .375
2 Feb 2019 Fri 1 .25
2 Feb 2019 Sat 3 .75
Notice the Month Year combos always add to 1.
Lastly, I would like to take the average of the Percent just calculated of ID 1 and 2
Month Year DOW Avg
Jan 2019 Fri 0.482
Jan 2019 Sat 0.518
Feb 2019 Fri 0.402
Feb 2019 Sat 0.597
The goal is to do so using dplyr