My data.frame is below:
group_id user_id
1000 26
1236 29
1236 46
3767 26
3767 46
5614 29
5614 45
5614 46
I need output as below:
User-1 User-2 #of-common-groups
26 26 2
26 46 1
29 29 2
29 45 1
29 46 2
45 29 1
45 45 1
45 46 1
46 26 1
46 29 2
46 45 1
46 46 3
Is there a quick way to achieve this? I actually have 137 distinct groups and about 81000 users.
The user 26 belongs to 2 groups and he also shares the same group 3767 with user 46. Hence
26 26 2
26 46 1
46 26 1
46 46 3 (user 46 belongs to 3 groups) etc