I have the following input:
C1 C2
1 1
1 1
1 2
1 3
1 4
2 1
. .
C1 and C2 are groups, where C2 is a nested group within C1. Now I'd like to build subgroups on C1 having a minimum size of 2. While the groups in C2 should not be split, I'd like to have as many groups as possible. Manually, I would first have a look at the group C1 and join subgroups 2, 3 and 4 together to (G=1) and take the subgroup 1 (C2=1) as a group (G=2). The expected output would be (where G are the groups I try to create)
C1 C2 G
1 1 1
1 1 1
1 2 2
1 3 2
1 4 2
2 1 3
. . .
I hope it's clear what I mean. Any help is highly appreciated.