title: Card Shuffle and Distribution in R
body: <p>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:</p>
  
  <pre><code>Player_1 &lt;- cards[sample(nrow(cards), 2), ]
  Player_1
  
  Remaining_Deck &lt;- sqldf('SELECT * FROM cards EXCEPT SELECT * FROM Player_1') # subset from t1 not in t2 
  
  Player_2 &lt;- cards[sample(nrow(Remaining_Deck), 2), ]
  Player_2
  
  Remaining_Deck2 &lt;- sqldf('SELECT * FROM Remaining_Deck EXCEPT SELECT * FROM Player_2') # subset from t1 not in t2 
  
  Player_3 &lt;- cards[sample(nrow(Remaining_Deck2), 2), ]
  Player_3
  
  Remaining_Deck3 &lt;- sqldf('SELECT * FROM Remaining_Deck2 EXCEPT SELECT * FROM Player_3') # subset from t1 not in t2 
  
  Player_1
  Player_2
  Player_3
  </code></pre>