Resampling
Learn how to mimic different activities of virtual resampling.
We'll cover the following...
Let’s now mimic our tactile resampling activity virtually with a computer.
Virtually resampling once
First, let’s perform the virtual analog of resampling once. Recall that the pennies_sample data frame included in the moderndive package contains the years of our original sample of 50 pennies from the bank. Furthermore, recall that we used the rep_sample_n() function as a virtual shovel to sample balls from our virtual bowl of 2,400 balls, as follows:
Let’s modify this code to perform the resampling with the replacement of the 50 slips of paper representing our original sample of 50 pennies
Observe how we explicitly set the replace argument to TRUE in order to tell rep_sample_n() that we would like to sample pennies with replacement. If we didn’t set replace = TRUE, the function would’ve assumed the default value of FALSE and done ...