Learn R Programming

SpaDES.core (version 0.2.4)

defineParameter: Define a parameter used in a module

Description

Used to specify a parameter's name, value, and set a default.

Usage

defineParameter(name, class, default, min, max, desc)

# S4 method for character,character,ANY,ANY,ANY,character defineParameter(name, class, default, min, max, desc)

# S4 method for character,character,ANY,missing,missing,character defineParameter(name, class, default, desc)

# S4 method for missing,missing,missing,missing,missing,missing defineParameter()

Arguments

name

Character string giving the parameter name.

class

Character string giving the parameter class.

default

The default value to use when none is specified by the user. Non-standard evaluation is used for the expression.

min

With max, used to define a suitable range of values. Non-standard evaluation is used for the expression.

max

With min, used to define a suitable range of values. Non-standard evaluation is used for the expression.

desc

Text string providing a brief description of the parameter.

Value

data.frame

See Also

P, params for accessing these parameters in a module.

Examples

Run this code
# NOT RUN {
parameters = rbind(
  defineParameter("lambda", "numeric", 1.23, desc = "intrinsic rate of increase"),
  defineParameter("P", "numeric", 0.2, 0, 1, "probability of attack")
)

# }
# NOT RUN {
# Create a new module, then access parameters using \code{P}
tmpdir <- file.path(tempdir(), "test")
checkPath(tmpdir, create = TRUE)

# creates a  new, "empty" module -- it has defaults for everything that is required
newModule("testModule", tmpdir)

# Look at new module code -- see defineParameter
file.edit(file.path(tmpdir, "testModule", "testModule.R"))

# initialize the simList
mySim <- simInit(modules = "testModule",
                 paths = list(modulePath = tmpdir))

# Access one of the parameters -- because this line is not inside a module
#  function, we must specify the module name. If used within a module,
#  we can omit the module name
P(mySim, "testModule")$.useCache

# }
# NOT RUN {

# }

Run the code above in your browser using DataLab