Name1 Col1 Col2 Col3 Name2 Col4 Col5 Col6 Col7
John A A A Alex B B B 1
Alex B B B John A A A 0
Looking at the data frame above, I would like to select the data based on the value of Col7. Specifically, if Col7 = 1 then I want to select Columns 1, 2, and 3. If Col7 = 0, then Cols 4,5,6 are selected. Cols 4,5,6 are the same variable as Cols 1,2,3 just associated to Alex instead of John (in row 1). Therefore, John's data is selected both times, and this will be the same for every pair.
I was thinking some form of select in "Dplyr" would work, but I am having trouble with the conditional selection aspect.
My final data frame would appear as follows:
Name1 Col1 Col2 Col3
John A A A
John A A A