[Maturing] A helper function that allows the selection of region specific settings if present and otherwise applies the overarching settings

filter_opts(opts, region)

Arguments

opts

Either a list of calls to an _opts() function or a single call to an _opts() function.

region

A character string indicating a region of interest.

Value

A list of options

Examples

# uses example case vector
cases <- example_confirmed[1:40]
cases <- data.table::rbindlist(list(
  data.table::copy(cases)[, region := "testland"],
  cases[, region := "realland"]
))

# regional options
regional_opts <- opts_list(rt_opts(), cases)
EpiNow2:::filter_opts(regional_opts, "realland")
#> $prior
#> $prior$mean
#> [1] 1
#> 
#> $prior$sd
#> [1] 1
#> 
#> 
#> $use_rt
#> [1] TRUE
#> 
#> $rw
#> [1] 0
#> 
#> $use_breakpoints
#> [1] TRUE
#> 
#> $future
#> [1] "latest"
#> 
#> $pop
#> [1] 0
#> 
#> $gp_on
#> [1] "R_t-1"
#> 
# default only
EpiNow2:::filter_opts(rt_opts(), "realland")
#> $prior
#> $prior$mean
#> [1] 1
#> 
#> $prior$sd
#> [1] 1
#> 
#> 
#> $use_rt
#> [1] TRUE
#> 
#> $rw
#> [1] 0
#> 
#> $use_breakpoints
#> [1] TRUE
#> 
#> $future
#> [1] "latest"
#> 
#> $pop
#> [1] 0
#> 
#> $gp_on
#> [1] "R_t-1"
#> 
# settings are NULL in one regions
regional_opts <- update_list(regional_opts, list(realland = NULL))
#> Error in list_recurse(.x, dots, function(x, y) y): `...` arguments must be either all named, or all unnamed
EpiNow2:::filter_opts(regional_opts, "realland")
#> $prior
#> $prior$mean
#> [1] 1
#> 
#> $prior$sd
#> [1] 1
#> 
#> 
#> $use_rt
#> [1] TRUE
#> 
#> $rw
#> [1] 0
#> 
#> $use_breakpoints
#> [1] TRUE
#> 
#> $future
#> [1] "latest"
#> 
#> $pop
#> [1] 0
#> 
#> $gp_on
#> [1] "R_t-1"
#>