Suppose this is my data:
X Y Z
1 1 2323
1 1 45
1 1 67
1 2 1
1 2 90
1 3 34
1 3 1267
1 3 623
1 4 81
1 4 501
2 1 456
2 1 78
2 2 41
2 2 56
2 3 90
2 3 71
2 4 24
2 4 98
2 5 42
2 5 361
How do I count the values of Z
for each unique variable Y
for each separate X
so that I can get a dataframe that looks like:
X Y Z
1 1 2435
1 2 91
1 3 1924
1 4 582
2 1 534
2 2 97
2 3 161
2 4 122
2 5 403