I want to create several variables which count the occurrence times of var
's value for each user.id
. Here is an example:
user.id var
1 A
1 B
2 A
2 A
2 C
3 C
Expected result:
user.id var_A var_B var_C
1 1 1 0
2 2 0 1
3 0 0 1