Feels like this should be straightforward but I have been through stack overflow and combn help, and cannot see solution.
The below players need to be in teams of 3 versus 2. I need to find all possible combinations of teams. For example two possible teams are "Ross", "Bobby" and "Casper" in one team, and "Max" and "Jake" in the other team. How can I code this?
players <- c("Ross", "Bobby", "Max", "Casper", "Jake")
I think the key step is to randomly choose 3 (or 2) out of 5 players to generate the first team, and the remaining are naturally assigned to the second team.
Probably you can try it like this
or if you don't mind the time efficiency, you can use
setdiffinsteadand either of which gives
Benchmarking
and we will see