Grids of combinations of variables (or parameters) can be created from a list of scenarios contaning all possible values for each variables. Such a grid can be used when conditioning an operating model around the structural uncertainty of fixed parameters and submodel choices. And it can also be used to create a range of combinations of management procedure parameters for tuning and selection of MPs.

expandGrid(scenarios, ..., names = FALSE)

gridList(scenarios, ..., grid = missing)

## Arguments

scenarios Values and levels for each run variable, list. Extra arguments, see Details. Should the table output contain names (FALSE) or indices (TRUE, default). Index table with grid to be converted into input list.

## Value

A data.frame or list.

## Details

The list of scenarios used as input should contain one element per variable, be it either a vector or a list of alternative values. The list must be named, and elements of class list should themselves be named. Names are added to vector elements by calling as.character() on their content. See examples below for guidance.

FLComp

## Examples

# Lists of scenarios can contains vectors ...
list(steepness=c(0.6, 0.7, 0.8), M=c(0.2, 0.3, 0.4))#> $steepness #> [1] 0.6 0.7 0.8 #> #>$M
#> [1] 0.2 0.3 0.4
#> # lists ...
list(M=list(0.2, 0.4, lo=seq(0.2, 0.4, length=10)))#> $M #>$M[[1]]
#> [1] 0.2
#>
#> $M[[2]] #> [1] 0.4 #> #>$M$lo #> [1] 0.2000000 0.2222222 0.2444444 0.2666667 0.2888889 0.3111111 0.3333333 #> [8] 0.3555556 0.3777778 0.4000000 #> #> # or both scenarios <- list(steepness=c(0.7, 0.8), M=list(0.2, 0.4, lo=seq(0.2, 0.4, length=10))) # Create full grid as index table expandGrid(scenarios)#> steepness M #> 1 1 1 #> 2 2 1 #> 3 1 2 #> 4 2 2 #> 5 1 3 #> 6 2 3# Drop certain combinations expandGrid(scenarios, M == 0.2 & steepness == 0.7, M == "lo" & steepness == 0.8)#> steepness M #> 1 2 1 #> 2 1 2 #> 3 2 2 #> 4 1 3# Output as names expandGrid(scenarios, M == 0.2 & steepness == 0.7, names=TRUE)#> steepness M #> 1 0.8 0.2 #> 2 0.7 0.4 #> 3 0.8 0.4 #> 4 0.7 lo #> 5 0.8 lo# Create list of variable combinations runs <- gridList(scenarios) runs[[1]]#>$steepness
#> [1] 0.7
#>
#> $M #>$M[[1]]
#> [1] 0.2
#>
#> length(runs)#> [1] 6# Create list but dropping certain combinations
runs <- gridList(scenarios, M == 0.2 & steepness == 0.7)
runs[[1]]#> $steepness #> [1] 0.7 #> #>$M
#> \$M[[1]]
#> [1] 0.2
#>
#> length(runs)#> [1] 5