I would like to adjust my frequency table by taking together a range of values. Giving the following frequency table:
Points Freq.x Freq.y
0 1 1
1 0 5
2 2 20
3 5 32
5 9 56
6 5 89
7 3 41
8 2 8
9 0 5
10 0 1
The values for Points should be combined for 3 consecutive numbers. For example: the frequencies for Points 0, 1 and 2 should be combined into 1 value for Freq.x (1+0+2=3) and 1 value for Freq.y (1+5+20=26). This would result in the following output:
Points Freq.x Freq.y
0 3 26
3 14 88
6 10 138
9 0 6
As you can see, the frequency of Points = 4 is missing. This should just count as if Freq.x and Freq.y for Points equal to 4 is 0.
Does anyone have an idea on how to tackle this problem in R?
I know how to make the cuts in Points, I just don't know how to take the sum of the appropriate frequencies.
cut(df$Points, breaks = seq(from = min(df$Points), to = max(df$Points), by = 3))