Suppose I have a character vector of even length (e.g. players = c("Chris", "Fred", "Brian", "James", "Bill", "Hicham")), I would like to randomly generate n = unique pairs per player.
For now I figured out how to generate all possible pairs:
matchup <- data.frame(t(combn(players, 2)))
I'm looking for a solution to pick n number of random pairs per players in that vector.
The expected output would be that each player in the vector has n number of matchups, so if n = 3, it could be something like:
X1 X2
1 James Bill
2 Chris Hicham
3 Fred Bill
4 Chris Bill
5 James Brian
6 Brian Hicham
7 Chris Brian
8 James Fred
9 Fred Hicham
James : 3 matchup
Chris : 3 matchup
Hicham : 3 matchup
Fred : 3 matchup
Brian : 3 matchup
Bill : 3 matchup
