You can use the aggregate
function:
aggregate(tot_count ~ customer_id + event_type, X, sum)
customer_id event_type tot_count
1 231 1 3
2 333 1 21
3 444 1 1
4 931 1 5
5 231 2 6
6 444 2 43
7 333 3 9
8 931 3 3