parameter_grid: Generate parameter combinations

View source: R/workflows.R

parameter_gridR Documentation

Generate parameter combinations

Description

Generate parameter combinations

Usage

parameter_grid(
  ...,
  n = 10L,
  method = c("grid", "random", "latin_hypercube"),
  seed = NULL
)

Arguments

...

Named vectors, one per parameter. Under method = "grid" every element is a level of a full factorial crossing. Under the sampling methods a length-2 numeric vector is read as a c(minimum, maximum) range to draw from, and any other vector is sampled from with replacement.

n

Single positive whole number of rows to draw for the "random" and "latin_hypercube" methods, default 10. Ignored by "grid", whose row count is the product of the parameter lengths.

method

One of "grid" (the default), "random", or "latin_hypercube".

seed

Optional single random seed. It is applied for the sampling methods only and is restored on exit.

Value

A base data.frame with one row per parameter combination, a leading scenario_id column numbering the rows, and then one column per parameter in the order given.

Examples

# Full factorial grid over named parameters.
parameter_grid(sample_size = c(50, 100), effect = c(0.2, 0.5))

# Latin-hypercube sample of `n` draws over two ranges. Grid parameters are
# passed through `...`, so none of them may be called `n`, `method` or `seed`.
parameter_grid(
  sample_size = c(50, 200), effect = c(0, 1),
  n = 5, method = "latin_hypercube", seed = 1
)

simulab documentation built on Oct. 15, 2026, 5:08 p.m.