knitr::opts_chunk$set(cache = TRUE, echo = TRUE, eval = FALSE)
library(magrittr)
library(SpaDES)

The parts

  1. Initializing a simulation using simInit() creates a simList object.

  2. Running a simulation via a spades() call returns a modified simList object.

How are simulations specified?

A simList object is simply a structured data type containing various elements of a simulation.

The main components of a simList are:

  1. A list of modules used;
  2. The event queue;
  3. A description of the data (object) dependencies.

How SpaDES works: simLists

We can examine the simList object structure in the usual R fashion by printing (showing) it, or by using str():

emptySim <- simInit()
emptySim  # same as show(emptySim)
str(emptySim)

NOTE: simLists are S4 objects, so we can use getSlots() and slotNames() to examine the object.

See also ?simList

Exercises 03, numbers 2 & 3.

Accessing the parts of a simLists

wzxhzdk:2 wzxhzdk:3

How SpaDES works: spades()

Model specification

Simple examples (using demo modules) of simInit() and spades() calls.

Exercises 03, number 4, 5, & 6.

Using pre-built modules

  1. Browse for modules in our SpaDES module repository:

    https://github.com/PredictiveEcology/SpaDES-modules

  2. Download a module, its data, and required packages:

    r module.path <- file.path(dirname(tempdir()), "modules") downloadModule('wolfAlps', module.path, data = FALSE) downloadData('wolfAlps', module.path) f <- file.path(module.path, 'wolfAlps', 'wolfAlps.R') pkgs <- packages(filename = f) install.packages(pkgs)

Customizing an existing module

Important: always make a copy of the module you wish to modify before editing!

Open the module's code file in your editor:

openModules('wolfAlps', module.path)  # opens only the named module
openModules(path = module.path)       # opens all modules in a directory

Next steps

Building SpaDES modules from scratch (slides).



PredictiveEcology/SpaDES.Workshops documentation built on Jan. 30, 2021, 6:52 p.m.