get_params_per_sit: Return a list of parameters active for a given situation

View source: R/get_params_per_sit.R

get_params_per_sitR Documentation

Return a list of parameters active for a given situation

Description

Return a list of parameters active for a given situation

Usage

get_params_per_sit(sit_groups, situation, param_vec)

Arguments

sit_groups

Defines the groups of situations for each parameter A named list containing for each parameter the list of situations per group (sit_list)

situation

The name of the situation

param_vec

The (named)vector of parameters from which to extract values

Details

Names of parameters in param_vec and sit_groups should be the same. If param_vec is not named, the parameters in param_vec will be considered in the same order as in sit_group

Value

A subvector of param_vec containing only the values that are active for the given situation

Examples

sg <- list(
  p1 = list(sit_list = list(
    c("sit1", "sit2", "sit3"),
    c("sit4", "sit5", "sit6")
  )),
  p2 = list(sit_list = list(c(
    "sit1", "sit2", "sit3", "sit4", "sit5",
    "sit6"
  ))),
  p3 = list(sit_list = list(c("sit1", "sit2", "sit3"), c(
    "sit4", "sit5",
    "sit6"
  )))
)
vec <- c(1, 2, 3, 4, 5)
names(vec) <- CroptimizR:::get_params_names(sg)
CroptimizR:::get_params_per_sit(sg, "sit2", vec)
# should give c(p1=1,p2=3,p3=4)
CroptimizR:::get_params_per_sit(sg, "sit4", vec)
# should give c(p1=2,p2=3,p3=5)

SticsRPacks/CroptimizR documentation built on Dec. 16, 2024, 11:54 a.m.