mock_categorical() is the simple direct API for categorical variables. It
returns a validated mock_spec; it does not generate data.
Arguments
- name
Variable name.
- levels
Character vector of valid levels or codes.
- proportions
Optional probabilities aligned to
levels.- rtype
R output type. Defaults to
"factor".- missing_codes
Explicit missing-code values.
- missing_proportions
Missing-code probabilities aligned to
missing_codes.- garbage_rules
List of intentional invalid-value rules.
- provenance
Optional provenance metadata. Defaults to the direct API.
- model_hint
Backend hint.
- spec_version
Character version of the specification shape.
Details
Use mock_categorical() when specifying one variable directly in R code. Use
mock_spec_categorical() with mock_spec() when composing several variables
or when writing an adapter from another metadata source.
See also
mock_spec(), mock_spec_categorical()
Other direct specification APIs:
mock_continuous(),
mock_date()
Examples
smoking_spec <- mock_categorical(
"smoking",
levels = c("never", "former", "current"),
proportions = c(0.5, 0.3, 0.2),
rtype = "character"
)
validate_mock_spec(smoking_spec)
#> MockData mock_spec validation result: valid