次のようなデータセット X があります。
customer_id event_type tot_count
931 1 5
231 2 6
231 1 3
333 3 9
444 1 1
931 3 3
333 1 21
444 2 43
customer_id
とevent_type
レベルの合計が必要です。これは、次のような SQL の 1 行のコードです。
select customer_id, event_type, sum(tot_count) from X group by 1,2
Rでも同じ操作が必要です。