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.

## Arguments

- n
Number of values to draw

- levels
Character vector specifying the levels for the factor

- prob
Vector specifying the probability for each factor level

## Value

Sample of `n`

values from `levels`

, drawn in proportion to their
probabilities. By default, levels are equally likely.

## See also

`by_level()`

to assign numeric values based on factor levels, such
as to set population regression coefficients by factor level