Closed CeresBarros closed 2 years ago
full reprex
options(repos = c(CRAN = "https://cloud.r-project.org"))
tempDir <- tempdir()
pkgPath <- file.path(tempDir, "packages", version$platform,
paste0(version$major, ".", strsplit(version$minor, "[.]")[[1]][1]))
dir.create(pkgPath, recursive = TRUE)
.libPaths(pkgPath, include.site = FALSE)
if (!require(Require, lib.loc = pkgPath)) {
install.packages("Require")
library(Require, lib.loc = pkgPath)
}
setLinuxBinaryRepo()
Require("PredictiveEcology/SpaDES.project@6d7de6ee12fc967c7c60de44f1aa3b04e6eeb5db",
require = FALSE, upgrade = FALSE, standAlone = TRUE)
paths <- list(inputPath = normPath(file.path(tempDir, "inputs")),
cachePath = normPath(file.path(tempDir, "cache")),
modulePath = normPath(file.path(tempDir, "modules")),
outputPath = normPath(file.path(tempDir, "outputs")))
SpaDES.project::getModule(modulePath = paths$modulePath,
c("PredictiveEcology/Biomass_core@master"),
overwrite = TRUE)
## make sure all necessary packages are installed:
outs <- SpaDES.project::packagesInModules(modulePath = paths$modulePath)
Require(c(unname(unlist(outs)), "SpaDES"),
require = FALSE, standAlone = TRUE)
## load necessary packages
Require(c("SpaDES", "LandR", "reproducible"), upgrade = FALSE, install = FALSE)
times <- list(start = 0, end = 30)
studyArea <- Cache(randomStudyArea, size = 1e7) # cache this so it creates a random one only once on a machine
# Pick the species you want to work with – using the naming convention in "Boreal" column of LandR::sppEquivalencies_CA
speciesNameConvention <- "Boreal"
speciesToUse <- c("Pice_Gla", "Popu_Tre", "Pinu_Con")
sppEquiv <- sppEquivalencies_CA[get(speciesNameConvention) %in% speciesToUse]
# Assign a colour convention for graphics for each species
sppColorVect <- sppColors(sppEquiv, speciesNameConvention,
newVals = "Mixed", palette = "Set1")
## Usage example
modules <- as.list("Biomass_core")
objects <- list(studyArea = studyArea, sppEquiv = sppEquiv, sppColorVect = sppColorVect)
successionTimestep <- 10L
## keep default values for most parameters
## (omitted from this list)
parameters <- list(
Biomass_core = list(
"sppEquivCol" = speciesNameConvention
, "successionTimestep" = successionTimestep
, ".plots" = c("screen", "object")
, ".plotInitialTime" = times$start
, ".plots" = c("screen", "png")
, ".saveInitialTime" = times$start
, ".useCache" = "init"
, ".useParallel" = FALSE
)
)
outputs <- data.frame(expand.grid(objectName = "cohortData",
saveTime = unique(seq(times$start, times$end, by = 1)),
eventPriority = 1,
stringsAsFactors = FALSE))
graphics.off()
mySim <- simInitAndSpades(times = times,
params = parameters,
modules = modules,
objects = objects,
paths = paths,
outputs = outputs,
debug = TRUE)
🤔 I can't reproduce this anymore. something must've been screwed up during my run.
I have used a workflow to install all necessary packages in a temporary directory, which seems to work well. However, when I run
simInitAndSpades
with the defaultoptions("spades.useRequire")
,Require
tries to reinstall all packages in a different location‘D:/GitHub/LandR-Manual/reproducible/4.2’
and I'm not even sure where's it's getting it from...