This is a wrapper around [sample()] to make selecting random enum values easier.

sample_enum(enum_type, size, replace = FALSE, weight = NULL)

Arguments

enum_type

Object that passes [is.enum_type()] check.

size

A non-negative integer giving number of items to choose.

replace

Should sampling be with replacement?

weight

Sampling weights. This must evaluate to a vector of non-negative numbers the same length as the input. Weights are automatically standardised to sum to 1.

Value

A list of enum values of length size drawn from enum_type's values.