grid | R Documentation |
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)
scenarios |
Values and levels for each run variable, list. |
... |
Extra arguments, see Details. |
names |
Should the table output contain names ( |
grid |
Index table with grid to be converted into input list. |
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.
A data.frame
or list
.
Iago Mosqueira, EC JRC
FLComp
# Lists of scenarios can contains vectors ...
list(steepness=c(0.6, 0.7, 0.8), M=c(0.2, 0.3, 0.4))
# lists ...
list(M=list(0.2, 0.4, lo=seq(0.2, 0.4, length=10)))
# 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)
# Drop certain combinations
expandGrid(scenarios, M == 0.2 & steepness == 0.7, M == "lo" & steepness == 0.8)
# Output as names
expandGrid(scenarios, M == 0.2 & steepness == 0.7, names=TRUE)
# Create list of variable combinations
runs <- gridList(scenarios)
runs[[1]]
length(runs)
# Create list but dropping certain combinations
runs <- gridList(scenarios, M == 0.2 & steepness == 0.7)
runs[[1]]
length(runs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.