I have a table, that has the following format
time ID
1 4024
1 4024
1 4025
1 4016
2 4024
2 4025
2 4025
3 4024
3 4016
3 4016
I want to count the frequence for each ID in each time point. For instance, I would like to generate the following table based on the above table
time 4024 4025 4016
1 2 1 1
2 1 2 0
3 1 0 2
It seems that aggregate
function can help, but how to use it for this case. Thanks.