Generate mock data with the native backend
Source:R/mock_spec_native.R
generate_mock_data_native.Rdgenerate_mock_data_native() consumes a validated mock_spec and generates
baseline valid values using MockData's native R backend. This milestone does
not yet apply missing-code injection, garbage values, diagnostics, formula
evaluation, or optional simstudy features.
Details
The native backend is the default MIT-licensed baseline engine. It currently
supports uniform continuous variables, truncated-normal continuous variables,
categorical variables, and uniform calendar dates. Missing codes, garbage
values, and diagnostics are intentionally handled by postprocess_mock_data()
so that all backends share the same audit trail.
If seed is supplied, the previous R random state is restored after
generation. This gives reproducible output without advancing the caller's RNG
stream. Formula variables are rejected loudly until the formula/dependency
milestone promotes the spike evaluator into production.
Examples
spec <- mock_spec(
mock_spec_continuous("age", range = c(18, 85), rtype = "integer"),
mock_spec_categorical(
"smoking",
levels = c("never", "former", "current"),
proportions = c(0.5, 0.3, 0.2)
)
)
data <- generate_mock_data_native(spec, n = 10, seed = 1)
head(data)
#> age smoking
#> 1 36 never
#> 2 43 never
#> 3 56 former
#> 4 79 never
#> 5 32 former
#> 6 78 never