R: Get parameter subset of only certain parameters.

filterParams {ParamHelpers} | R Documentation

## Get parameter subset of only certain parameters.

### Description

Parameter order is not changed. It is possible to filter via multiple arguments, e.g., first filter based on id, then the type and lastly tunable. The order in which the filters are executed is always fixed (id > type > tunable).

### Usage

    filterParams(par.set, ids = NULL, type = NULL, tunable = c(TRUE, FALSE),
      check.requires = FALSE)

    filterParamsNumeric(par.set, ids = NULL, tunable = c(TRUE, FALSE),
      include.int = TRUE)

    filterParamsDiscrete(par.set, ids = NULL, tunable = c(TRUE, FALSE),
      include.logical = TRUE)

### Arguments

`par.set` | [`ParamSet`] Parameter set.
`ids` | [`NULL` | `character`] Vector with id strings containing the parameters to select. Has to be a subset of the parameter names within the parameter set. Per default (`ids = NULL`) no filtering based on names is done.
`type` | [`NULL` | `character`] Vector of allowed types, subset of: “numeric”, “integer”, “numericvector”, “integervector”, “discrete”, “discretevector”, “logical”, “logicalvector”, “character”, “charactervector”, “function”, “untyped”. Setting `type = NULL`, which is the default, allows the consideration of all types.
`tunable` | [`logical`] Vector of allowed values for the property `tunable`. Accepted arguments are `TRUE`, `FALSE` or `c(TRUE, FALSE)`. The default is `c(TRUE, FALSE)`, i.e. none of the parameters will be filtered out.
`check.requires` | [`logical(1)`] Toggle whether it should be checked that all requirements in the `ParamSet` are still valid after filtering or not. This check is done after filtering and will throw an error if those Params are filtered which other Params need for their requirements. Default is `FALSE`.
`include.int` | [`logical(1)`] Are integers also considered to be numeric? Default is `TRUE`.
`include.logical` | [`logical(1)`] Are logicals also considered to be discrete? Default is `TRUE`.

### Value

[`ParamSet`].

### Examples

    ps = makeParamSet(
      makeNumericParam("u", lower = 1),
      makeIntegerParam("v", lower = 1, upper = 2),
      makeDiscreteParam("w", values = 1:2),
      makeLogicalParam("x"),
      makeCharacterParam("s"),
      makeNumericParam("y", tunable = FALSE)
    )

    # filter for numeric and integer parameters
    filterParams(ps, type = c("integer", "numeric"))

    # filter for tunable, numeric parameters
    filterParams(ps, type = "numeric", tunable = TRUE)

    # filter for all numeric parameters among "u", "v" and "x"
    filterParams(ps, type = "numeric", ids = c("u", "v", "x"))

[Package ParamHelpers version 1.11 Index]