I have the following table:
Group Value
---- ----
1 A
1 B
1 C
1 D
2 A
2 B
2 C
For each of the two groups, I want to return all possible combinations of values. For group 1, e.g., the possible combinations of are (A,B), (A,C), (A,D), (B,C), (B,D), (C,D), (A,B,C), (B,D,C), (D,C,A), (C,A,B). Analogous, for group 2 it is (A,B), (A,C), (B,C) [Remark: I don't want to consider (1) the combintions with just one value, (2) the combination with all values and (3) the combination with no values. Thus I have 2^(n)-n-1-1 combinations for n different values].
I want to list all those combinations with the help of an additional column "Combi". This column numbers the different combinations consecutively.
Group Combi Value
---- ---- ----
1 1 A
1 1 B
1 2 A
1 2 C
1 3 A
1 3 D
1 4 B
1 4 C
1 5 B
1 5 D
1 6 C
1 6 C
1 7 A
1 7 B
1 7 C
1 8 B
1 8 C
1 8 D
1 9 C
1 9 D
1 9 A
1 10 D
1 10 A
1 10 B
2 11 A
2 11 B
2 12 A
2 12 C
2 13 B
2 13 C
How do I do this in R?