# LAB: Simulation

This is the lab associated with the lesson on Simulation in R.

Please upload your final completed lab on the Assignments page in Canvas, as per the instructions below.

You are welcome and expected to ask for help from the instructors if you get stuck: Please also come to the R Bootcamp on Friday—there is coffee and snacks!

# Playing cards

In the lesson, we simulated flipping a coin and rolling a die. You can also use R to simulate a pack of playing cards (52 cards, 13 of each suit: 1–10, Jack, Queen, King, and Ace).

1. Write code to programatically generate a vector of 52 cards of the correct suit and value.

2. Let’s play … Snap!

Sample the deck to simulate a game with two players. First, deal the cards, 26 to each player. Then, in each round each player plays one card from their half of the pack. There is no need to work out which cards make a Snap!.

## How to write up your answers

Please check the help page for a reminder, if you need to.

Updated: 2017-10-15