I have these columns in a data frame that look like:
combination color_1 color_2
1_1 red red
1_2 red blue
1_3 red green
1_4 red yellow
2_1 blue red
2_2 blue blue
2_3 blue green
2_4 blue yellow
...
Based off matching the color_1 and color_2 values, I would like to be able to create new columns that outputs the result of the match. There are certain specifications to this. For the first row where "red" and "red" are the same, the output in the new column (e.g. "Red-Only") should be a "1", and then "2" for every other match. Then, I would repeat this code but then picking up on matches where "blue" and "blue" occur, to output "1" in a next column (e.g. "Blue-Only") and "2" everywhere else. This goes for Yellow-only matches, Green-only matches, etc. So at the end I would have 4 extra columns depending on the condition.
Thanks for the help in advance!