## ---- 1. Portable: take everything with you ----
projectPath <- file.path(tempdir(), "myProject")
outPath <- file.path(projectPath, "outputs")
dir.create(outPath, recursive = TRUE, showWarnings = FALSE)
sim <- simInit(times = list(start = 0, end = 1, timeunit = "year"),
paths = list(outputPath = outPath))
sim$anObject <- 1:10
saveSimList(sim, file.path(projectPath, "portable.rds"),
projectPath = projectPath)
## unpack it anywhere -- pass the new location as projectPath
sim2 <- loadSimList(file.path(projectPath, "portable.rds"),
projectPath = projectPath)
sim2$anObject
## ---- 2. In place: metadata only, files stay put ----
## `files = FALSE` skips bundling; the run's own files are left where
## they are, and the reloaded simList tells you where to find them
saveSimList(sim, file.path(projectPath, "inPlace.rds"),
projectPath = projectPath, files = FALSE)
sim3 <- loadSimList(file.path(projectPath, "inPlace.rds"),
projectPath = projectPath)
outputPath(sim3) # where the run wrote its outputs
outputs(sim3) # the manifest of what it wrote
unlink(projectPath, recursive = TRUE)
Run the code above in your browser using DataLab