Learn R Programming

SpaDES.core (version 2.0.5)

paramCheckOtherMods: Test and update a parameter against same parameter in other modules

Description

This function is intended to be part of module code and will test whether the value of a parameter within the current module matches the value of the same parameter in other modules. This is a test for parameters that might expect to be part of a params = list(.globals = list(someParam = "test")) passed to simInit.

Usage

paramCheckOtherMods(
  sim,
  paramToCheck,
  moduleToUse = "all",
  ifSetButDifferent = c("error", "warning", "message", "silent"),
  verbose = getOption("reproducible.verbose")
)

Value

If the value of the paramToCheck in the current module is either NULL or "default", and there is only one other value across all modules named in moduleToUse, then this will return a character string with the value of the single parameter value in the other module(s). It will return the current value if there are no other modules with the same parameter.

Arguments

sim

A simList object

paramToCheck

A character string, length one, of a parameter name to check and compare between the current module and one or more or all others

moduleToUse

A character vector of module names to check against. This can be "all" which will compare against all other modules.

ifSetButDifferent

A character string indicating whether to "error" the default, or send a "warning", message or just silently continue (any other value).

verbose

Logical or Numeric, follows reproducible.verbose value by default.

Details

It is considered a "fail" under several conditions:

  1. current module has a value that is not NULL or "default" and another module has a different value;

  2. there is more than one value for the paramToCheck in the other modules, so it is ambiguous which one to return.

Either the current module is different than other modules, unless it is "default" or NULL.