knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = TRUE ) SuggestedPkgsNeeded <- c("SpaDES.core", "igraph", "visNetwork", "ellipsis", "terra", "raster") hasSuggests <- all(sapply(SuggestedPkgsNeeded, require, character.only = TRUE, quietly = TRUE)) useSuggests <- !(tolower(Sys.getenv("_R_CHECK_DEPENDS_ONLY_")) == "true") scalls <- sys.calls() a <- format(scalls) # Run everything during `pkgdown::build_*` (which uses rmarkdown::render) knitr::opts_chunk$set(eval = hasSuggests && useSuggests && Sys.info()["user"] == "emcintir" && any(grepl("rmarkdown::render", a)))# && interactive()) options(Ncpus = 1) if (Sys.info()["user"] == "emcintir") { knitr::opts_knit$set(root.dir = Require::checkPath(file.path("c:/Eliot/tmp", "listModules"), create = TRUE )) } else { knitr::opts_knit$set(root.dir = Require::checkPath(file.path(tempdir(), "listModules"), create = TRUE )) } knitr::opts_chunk$set(fig.width=9, fig.height=7) # sets html figure height and width # options(Require.clonePkgs = TRUE)
## cleanup / restore state if (is.null(getOption("repos")) || !"CRAN" %in% names(getOption("repos"))) { options(repos = c(CRAN = "https://cloud.r-project.org")) }
if (!require("SpaDES.project")) { {install.packages("SpaDES.project", repos = c("predictiveecology.r-universe.dev", getOption("repos"))) require("SpaDES.project")} }
One powerful aspect of SpaDES
is the ability to connect to other people's modules. It can be challenging to know where other modules are and what they do. Using the listModules
function.
The command sequence we will use is:
listModule
to identify which modules exist on cloud storage systems,getModules
to bring them (or a subset) to your local machine,moduleDependencies
to do the metadata analysis, moduleDependenciesToGraph
converts them to a graph, moduleDependenciesToGraph
to visualize that graph.A user can use only some of these steps if they do not want to produce the visuals.
This will search the PredictiveEcology
github.com repository for any SpaDES module whose name has Biomass_species
, Biomass_core
, Biomass_regen
in it. The search will find any module that contains those keywords, i.e., Biomass_regen
will find Biomass_regeneration
## cleanup / restore state # SpaDES.project::.teardownProject(out$paths, origLibPaths)
Account <- "PredictiveEcology" grepListShort <- "Biomass_species|Biomass_core|Biomass_regen" mods <- listModules(grepListShort, accounts = Account) modPath <- normPath(tempdir2()) getModule(mods, modulePath = modPath) DT <- moduleDependencies(mods, modulePath = modPath) graph <- moduleDependenciesToGraph(DT) (vn <- PlotModuleGraph(graph))
Account <- "PredictiveEcology" grepListShort <- "fireSense" mods <- listModules(grepListShort, accounts = Account) getModule(mods, modulePath = modPath) DT <- moduleDependencies(mods, modulePath = modPath) graph <- moduleDependenciesToGraph(DT) (vn <- PlotModuleGraph(graph))
Account <- "PredictiveEcology" grepListShort <- "Biomass_|LandR" mods <- listModules(grepListShort, accounts = Account) getModule(mods, modulePath = modPath) DT <- moduleDependencies(mods, modulePath = modPath) graph <- moduleDependenciesToGraph(DT) (vn <- PlotModuleGraph(graph))
# Can do same, but with long list -- not done here -- can try accountsListLong <- c("PredictiveEcology", "ianmseddy", "achubaty", "FOR-CAST", "eliotmcintire", "tati-micheletti", "CeresBarros") grepListLong <- c("Biomass", "WBI", "LandR", "fireSense", "CBM", "LandMine", "LandWeb", "NRV", #"scfm", "priority", "fire", "dataPrep", "DataPrep", "RoF", "Ontario", "ROF") modsLong <- listModules(grepListLong, accounts = accountsListLong) # pass to listModules for much larger figure getModule(modsLong, modulePath = modPath) DT <- moduleDependencies(modsLong, modulePath = modPath) graph <- moduleDependenciesToGraph(DT) (vn <- PlotModuleGraph(graph))
This takes much longer to run as it scans all (open) repositories for each element of accounts
. It will search for a relatively "lightweight" indicator of a SpaDES module, namely, a file at the top level that has the same name as the repository, but whose file extension is .R
.
# Can do same, but with long list -- not done here -- can try accountsListLong <- c("PredictiveEcology", "ianmseddy", "achubaty", "FOR-CAST", "eliotmcintire", "tati-micheletti", "CeresBarros") modsLong <- listModules(accounts = accountsListLong) # pass to listModules for much larger figure getModule(modsLong, modulePath = modPath) DT <- moduleDependencies(modsLong, modulePath = modPath) graph <- moduleDependenciesToGraph(DT) (vn <- PlotModuleGraph(graph))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.