Draw random values from a factor variableSource:
To specify the population distribution of a factor variable, specify the probability for each of its factor levels. When drawn from the population, factor levels are drawn with replacement according to their probability.
Number of values to draw
Character vector specifying the levels for the factor
Vector specifying the probability for each factor level
n values from
levels, drawn in proportion to their
probabilities. By default, levels are equally likely.
by_level() to assign numeric values based on factor levels, such
as to set population regression coefficients by factor level