December 2017
Beginner to intermediate
470 pages
12h 29m
English
The random_levels() function simulates n categorical values by sampling the levels provided with replacement (controlled by the third parameter, which is sent as TRUE). You can think about the levels as an array of strings, each of which is a possible value for the simulation. These levels will come from the categories defined for factor variables in the data frame (PROTEIN_SOURCE, STORE, DELIVERY, STATUS, and PAID). A sample with replacement means that every time we pick one of the values from the levels object, we return it so that we can pick it again later. Sampling without replacement only makes sense when you want a number of samples that is smaller than the total amount of values available, ...