SpaDES (version 1.2.0)

saveFiles: Save objects using .saveObjects in params slot of simInit

Description

In the simInit call, a parameter called .saveObjects can be provided in each module. This must be a character string vector of all object names to save. These objects will then be saved whenever a call to saveFiles is made.

Usage

saveFiles(sim)

Arguments

sim
A simList simulation object.

1. Model-level saving

Using the outputs slot in the simInit call. See 2nd example in simInit. This can be convenient because it gives overall control of many modules at a time, and there is an implicit scheduling that gets created during the simInit call.

2. Module-level saving

Using the saveFiles function inside a module. This must be accompanied by a .saveObjects list element in the params slot in the simInit call. Usually a module developer will create this method for future users of their module.

3. User saving

A user can save any object at any time inside their module. This is the least modular approach.

Details

The file names will be equal to the object name plus time(sim) is appended at the end. The files are saved as .rds files, meaning, only one object gets saved per file. For objects saved using this function, the module developer must create save events that schedule a call to saveFiles.

There are 3 ways to save objects using SpaDES.

Examples

Run this code
## Not run: 
#  sim <- saveFiles(mySim)
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace