Skip to contents

generate_mock_data_simstudy() consumes a validated mock_spec and generates baseline valid values through the optional simstudy package for supported uniform continuous and categorical variables. MockData remains responsible for missing-code injection, garbage values, and diagnostics through postprocess_mock_data().

Usage

generate_mock_data_simstudy(spec, n, seed = NULL)

Arguments

spec

A mock_spec object.

n

Non-negative whole number of rows to generate.

seed

Optional whole-number random seed. The previous R random state is restored after generation.

Value

A data frame with one column per mock_spec variable and n rows.

Details

Variables that need MockData semantics not covered by this milestone, such as truncated normal ranges and calendar dates, are generated by MockData's native path inside the same seeded call.

simstudy is an optional Suggests dependency and is GPL-3 licensed; MockData remains MIT licensed by keeping this backend soft-gated and by retaining generate_mock_data_native() as the default engine. Use this backend when simstudy is installed and you want to exercise the optional engine path. It currently delegates only categorical and uniform continuous baseline generation to simstudy; unsupported variables are routed through MockData's native backend so that a single specification can mix capabilities.

Missing-code assignment, garbage values, and diagnostics are not delegated to simstudy. They remain MockData-owned post-processing so both backends share the same auditability contract.

Examples

spec <- mock_continuous("age", range = c(18, 85), rtype = "integer")
if (requireNamespace("simstudy", quietly = TRUE)) {
  data <- generate_mock_data_simstudy(spec, n = 10, seed = 1)
  head(data)
}
#>   age
#> 1  36
#> 2  43
#> 3  56
#> 4  79
#> 5  32
#> 6  78