| shg_save_config | R Documentation |
Writes a YAML file containing smok_params_source, mort_params_source,
mort_params_type, engine settings (RNG, seeds, effective segment count),
fixed-run parameters (repeat, race, sex, cohort_year),
and immediate_cessation_year. Omits derived paths so the bundle stays
portable; those paths are restored by shg_load_params.
shg_save_config(shg, path, quiet = FALSE, results = NULL)
shg |
An |
path |
Destination file path (usually |
quiet |
If |
results |
Optional simulation |
Prefer the method form shg$save_config(path) (same implementation).
The functional form shg_save_config(shg, path) is a convenience wrapper.
Saving reads shg$getReproConfig(debug = FALSE) after your workflow. Portable
save is allowed only when the last completed simulation on this instance
was runSimFromFixedValues — a subsequent runSimFromDataFrame
(population run) clears that until you run runSimFromFixedValues again.
Use shg$last_completed_sim_was_fixed_cohort() to test programmatically.
The run scalars (repeat, race, sex, cohort_year) come
from that fixed cohort run. Engine fields (number_of_segments,
rng_strategy, seeds) reflect effective values from it when
you used defaults or auto settings for segments. Thread count is intentionally
omitted from the portable repro file (outcomes must not depend on it). Optional
results adds content hashes and compact numeric summaries for verification.
If results is omitted, the YAML has no results block and no
repro_digest (only engine and cohort fields for portability).
If the last run was not a fixed cohort simulation, or fixed cohort metadata are missing, saving fails with an error.
path, invisibly.
shg_load_config, shg_run
shg <- new(SHGInterface)
shg$input_data_folder <- system.file("extdata", "2018", package = "SmokingHistoryGenerator")
shg$smok_params_source <- "example-smoking"
shg$mort_params_source <- "example-mortality"
shg$mort_params_type <- "acm"
sim <- shg$runSimFromFixedValues(500, 0, 0, 1950)
tf <- tempfile(fileext = ".yml")
shg_save_config(shg, tf, results = sim)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.