parameters = rbind(
defineParameter("lambda", "numeric", 1.23, desc = "intrinsic rate of increase"),
defineParameter("P", "numeric", 0.2, 0, 1, "probability of attack"),
# multi-line desc without quotes on each line -- spaces and carriage returns are stripped
defineParameter("rate", "numeric", 0.2, 0, 1,
"rate of arrival. This is in individuals
per day. This can be modified
by the user"),
# multi-line desc with quotes on each line
defineParameter("times", "numeric", 0.2, 0, 1,
desc = "The times during the year ",
"that events will occur ",
"with possibility of random arrival times")
)
# \donttest{
# Create a new module, then access parameters using `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, open = FALSE)
# Look at new module code -- see defineParameter
if (interactive()) file.edit(file.path(tmpdir, "testModule", "testModule.R"))
# initialize the simList
if (requireNamespace("ggplot2", quietly = TRUE)) {
# Some things not necessary in this example, if not interactive (like plotting)
opts <- if (interactive()) list() else
options(spades.plot = NA, spades.useRequire = FALSE,
spades.moduleCodeChecks = FALSE)
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, module = "testModule") # gets all params in a module
P(mySim, ".useCache", "testModule") # just one param
options(opts)
}
unlink(tmpdir, recursive = TRUE)
# }
Run the code above in your browser using DataLab