The sample command can be used to simulate classic probability problems like drawing from an urn with and without replacement, or creating random permutations.
Note that throughout this example, set.seed is used to ensure that the example code is reproducible. However, sample will work without expl...