Skip to contents

Pure helper powering UI-to-IR synchronization in mod_spec_controls_server(). Never calls eval() or parse(); all values are coerced deterministically and checked against validate_spec_ir().

Usage

patch_spec_from_control(spec, control_id, value)

Arguments

spec

Current valid spec_ir object.

control_id

Character scalar ID matching a control from spec_to_controls().

value

New input value from Shiny.

Value

A list containing spec (candidate spec_ir), changed (logical), diff (spec_diff), and validation (spec_validation).

Examples

spec <- new_spec_ir(design_type = "multilevel_sim",
  hierarchy = list(levels = 2L, n_clusters = 40L, cluster_size = 20L, icc = 0.2))
res <- patch_spec_from_control(spec, "n_clusters", 75)
res$validation$valid
#> [1] TRUE
res$diff
#> 
#> ── spec_diff (1 change across 1 section) 
#> • hierarchy.n_clusters: 40 -> 75