I am trying to simulate a game of poker where I am required to distribute cards to "n" number of players playing at one point. I have written a brief piece of code that looks at the existing deck and gives out cards to other players however this is quite hard coded. I wonder if there is a way to do this activity without hard coding using "loop where one could define the number of players and the code is able to look the revised deck and gives new cards to other players. Here is what I have written so far:
Player_1 <- cards[sample(nrow(cards), 2), ]
Player_1
Remaining_Deck <- sqldf('SELECT * FROM cards EXCEPT SELECT * FROM Player_1') # subset from t1 not in t2
Player_2 <- cards[sample(nrow(Remaining_Deck), 2), ]
Player_2
Remaining_Deck2 <- sqldf('SELECT * FROM Remaining_Deck EXCEPT SELECT * FROM Player_2') # subset from t1 not in t2
Player_3 <- cards[sample(nrow(Remaining_Deck2), 2), ]
Player_3
Remaining_Deck3 <- sqldf('SELECT * FROM Remaining_Deck2 EXCEPT SELECT * FROM Player_3') # subset from t1 not in t2
Player_1
Player_2
Player_3