Riddler: Simulating a Week of Rain
Simulation
Notable topics: Simulation
Recorded on: 2018-12-11
Timestamps by: Alex Cookson
Screencast
Timestamps
Using crossing function to get all combinations of specified variables (100 trials of 5 days)
Using rbinom function to simulate whether it rains or not
Using ifelse function to set starting number of umbrellas at beginning of week
Explanation of structure of simulation and approach to determining number of umbrellas in each location
Changing structure so that we have a row for each day's morning or evening
Using group_by, ifelse, and row_number functions to set starting number of umbrellas for each trial
Using case_when function to returns different values for multiple logical checks (allows for more outputs than ifelse)
Using cumsum function to create a running tally of number of umbrellas in each location
Explanation of output of simulated data
Using any function to check if any day had a negative "umbrella count" (indicating there wasn't an umbrella available when raining)
Asking, "When was the first time Louie got wet?"
Creating a custom vector to convert an integer to a weekday (e.g., 2 = Tue)