jeudi 3 décembre 2020

R randomly assigning to groups with conditions

I would like to make a football world cup group stage draw generator, i.e. I have four pots with 8-8 teams with their names and their confederations, these teams needs to be randomly assigned to 8 groups from A to H and in each group should be 4 teams. I thought about assigning letters with the LETTERS() and sample() functions but the problem is that no group can have more than one team from any continental confederation with the exception of UEFA, which can have no more than 2 teams in one group. My pots are looking like this one pot:

           Team Confederation
1:        Ghana           CAF
2:       Serbia          UEFA
3:      Nigeria           CAF
4:      Morocco           CAF
5: Saudi Arabia           AFC
6:   Costa Rica      CONCACAF
7:     Colombia      CONMEBOL
8:        Chile      CONMEBOL

Can anybody help me with this?




Aucun commentaire:

Enregistrer un commentaire