Skip to contents

This function subsets the elements of a simulation results list to the specified indices. It excludes the "more_info" field by default but can optionally retain it.

Usage

subset_simulations(ind, simulation_results, keep_more_info = FALSE)

Arguments

ind

A vector of indices to subset the simulation results.

simulation_results

A list containing simulation results, where each element (except "more_info") is assumed to be indexable.

keep_more_info

Logical; if TRUE, the "more_info" field is retained in the output. Default is FALSE.

Value

A list of simulation results subset to the specified indices. If keep_more_info is TRUE, the "more_info" field is included unchanged.

Details

This function assumes that all elements of simulation_results, except "more_info", can be subset using the provided indices. A future enhancement could include a check to ensure that each field is indeed subsettable.

Examples

if (FALSE) {
results <- list(
  data = list(1:10, 11:20, 21:30),
  metrics = list(a = 1:3, b = 4:6),
  more_info = list(description = "Full simulation run")
)
subset_simulations(1:2, results, keep_more_info = TRUE)
}