I have a dataset with two colums, ID, Group.
ID Group
10 Red
11 Red
13 Blue
13 Red
15 Blue
15 Blue
17 Blue
17 Red
17 Red
19 Blue
19 Undecided
23 Blue
23 Undecided
23 Undecided
My goal is to create a third indicator column that takes a value based on the combination of values in ID and Group. Expecting a third column , Indicator like this.
ID Group Indicator
10 Blue Single
11 Blue Single
13 Blue Blue-Red
13 Red Blue-Red
15 Blue Blue-Blue
15 Blue Blue-Blue
17 Blue Blue-Red
17 Red Blue-Red
17 Red Blue-Red
19 Blue Blue-Undecided
19 Undecided Blue-Undecided
23 Blue Blue-Undecided
23 Undecided Blue-Undecided
23 Undecided Blue-Undecided
I tried case_when but it became too complicated and gave up. Any help in much appreciated. Thanks.
Here's a
case_whenversion usingdplyrthat doesn't have too many caseswhich produces
tested with