Restrict scenarios based on allowed scenarios

restrict_by_condition(
  sims,
  allowed_scenarios,
  restriction_var = c("scenario", "sample")
)

Arguments

sims

A data.table from scenario_analysis.

allowed_scenarios

A data.table of allowed scenarios. Must include a scenario and sample variable.

restriction_var

Character vector of variables to use to restrict scenarios. Defaults to "scenario" and "sample".

Value

A data frame of scenarios restricted by the allowed scenarios

Examples

## Example sims <- data.table::data.table(scenario = 1:10, sample = 1:10, value = 1:10) allowed_scenarios <- data.table::data.table(scenario = c(1,4,6), sample = c(1, 4, 6)) restrict_by_condition(sims, allowed_scenarios)
#> scenario sample value #> 1: 1 1 1 #> 2: 4 4 4 #> 3: 6 6 6
## Code restrict_by_condition
#> function (sims, allowed_scenarios, restriction_var = c("scenario", #> "sample")) #> { #> scenario <- NULL #> sample <- NULL #> allowed_scenarios <- allowed_scenarios[, colnames(allowed_scenarios) %in% #> restriction_var, with = FALSE] #> restrict_sims <- sims[allowed_scenarios, on = restriction_var] #> return(restrict_sims) #> } #> <bytecode: 0x55a6b0ef84f8> #> <environment: namespace:WuhanSeedingVsTransmission>