| runSimFromDataFrame | R Documentation |
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.
dfPopulation |
The input dataframe with named columns for race, sex, and birth_cohort |
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.
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.