I've used the following code to create a frequency count.
df %>% group_by(INCOME, HAPPY) %>% summarise(count=n())
Output:
INCOME HAPPY count
<int> <int> <int>
1 1 1 6
2 1 2 17
3 1 3 13
4 1 8 1
5 2 1 5
6 2 2 11
7 2 3 12
8 2 8 0
9 3 1 4
10 3 2 10
11 3 3 5
12 3 8 0
Yet, I would like to have the following frequency format.
1 2 3
1 6 5 4
2 17 11 10
3 13 12 5
8 1 0 0