knitr::opts_chunk$set(echo = TRUE, eval = FALSE)
age
object at 1, and increment it at each step of time
, or t
. In both cases time
and t
are the loop counters, but only in the second case is the counter being effectively "used" inside the loop.age <- 1 for (time in 1:10) { age <- age + 1 }
In SpaDES, events are first defined, then scheduled to happen at a particular point in time:
SpaDES
## initialisation age <- 1 ## boundaries times = list(start = 1, end = 10) ## event definition (content) aging <- function(age) { age <- age + 1 } ## event execution and scheduling events <- { doEvent("aging") scheduleEvent("aging", when = now + 1) }
SpaDES
Event execution and scheduling in SpaDES
use same components of a for-loop: initialize, bounds, step, content
This creates an event queue
# eventTime moduleName eventType # 1: 0 loop init # 2: 0 loop addOneYear # 3: 1 loop addOneYear # 4: 2 loop addOneYear # 5: 3 loop addOneYear # 6: 4 loop addOneYear # 7: 5 loop addOneYear # 8: 6 loop addOneYear # 9: 7 loop addOneYear # 10: 8 loop addOneYear # 11: 9 loop addOneYear # 12: 10 loop addOneYear
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.