runSimFromDataFrame: runSimFromDataFrame method

runSimFromDataFrameR Documentation

runSimFromDataFrame method

Description

runSimFromDataFrame offers a way to configure and run a simulation from an existing R dataframe. It returns a dataframe of simulated smoking histories with the same number of rows and order as the input dataframe.

Arguments

dfPopulation

The input dataframe with named columns for race, sex, and birth_cohort

Details

On Windows, output_file (direct disk output) cannot be combined with multi-threaded execution (num_threads not equal to 1). The call stops with an error before loading inputs or writing files. Use the default in-memory DataFrame return value, or set num_threads <- 1 to write a file.

Value

If attach_run_info = FALSE, a data.frame with one row per input individual (same order) and columns smoking_initiation_age (-999 = never smoker), smoking_cessation_age, age_at_death, and cigarettes_per_day. Constant race, sex, or birth_cohort are omitted when uniform. If attach_run_info = TRUE, the same four-component bundle as shg_run (results, original_config, repro_config, run_info); see that help page for definitions.

Examples

shg <- new(SHGInterface)
shg$input_data_folder <- system.file("extdata", "2018", package = "SmokingHistoryGenerator")
pop <- data.frame(race = 0, sex = 0, birth_cohort = 1950)
hist <- shg$runSimFromDataFrame(pop)
head(hist)

SmokingHistoryGenerator documentation built on June 13, 2026, 1:08 a.m.