Learn R Programming

ParamHelpers (version 1.7)

filterParams: Get parameter subset of only certain parameters.

Description

Parameter order is not changed.

Usage

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

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.

Value

[ParamSet].

Examples

Run this code
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"))

Run the code above in your browser using DataLab