-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathREADME.R
111 lines (80 loc) · 5.52 KB
/
README.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
# source("https://raw.githubusercontent.com/PredictiveEcology/SpaDES.Workshops/master/README.R")
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sys.which("make")
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
make
""
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
workshopPath = "~/SpaDESWorkshop"
modulePath = file.path(workshopPath, "modules")
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Restart your R session so it is clear
## Ctrl-shift-F10 if you are in Rstudio
source("https://raw.githubusercontent.com/PredictiveEcology/SpaDES-modules/master/R/SpaDES_Helpers.R")
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
installedPkgs <- installed.packages(.libPaths()[1])
if (!"Require" %in% rownames(installedPkgs))
install.packages("Require") # to make sure you have 2 dependencies (data.table, remotes)
if (!identical(as.character(packageVersion("Require")), "0.0.11"))
installGitHubPackage("PredictiveEcology/Require@development") # install latest version of Require
## ----for-isolated-package-folder-----------------------------------------------------------------------------------------------------------------------------------
# This isn't perfect as it will not be totally isolated
# .libPaths(file.path(workshopPath, "R"))
# if you want it fully isolated, you will have to run this file in 2 steps:
# Run this next line, then restart session
# Require::setup(file.path(workshopPath, "R"))
# Then restart your session and run it all again
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
installSpaDES()
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
Require::Require(
c("PredictiveEcology/LandR@development",
"PredictiveEcology/pemisc@development",
"tati-micheletti/usefulFuns",
"achubaty/amc@development"),
upgrade = "never",
which = c("Imports", "Depends", "Suggests"))
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (dir.exists(modulePath)) unlink(modulePath, recursive = TRUE)
# LandR Biomass modules (simulation modules)
getModule("PredictiveEcology/Biomass_core", modulePath = modulePath)
getModule("PredictiveEcology/Biomass_regeneration", modulePath = modulePath)
# LandR Biomass modules (data preparation modules)
getModule("PredictiveEcology/Biomass_borealDataPrep", modulePath = modulePath)
getModule("PredictiveEcology/Biomass_speciesData", modulePath = modulePath)
# SCFM fire modules
getModule("PredictiveEcology/scfm@development", modulePath = modulePath, overwrite = TRUE)
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
# If you have been using the binary package manager for Ubuntu, you have to turn it off
if (isTRUE(grepl("packagemanager", getOption("repos")[["CRAN"]])))
options("repos" = c(CRAN = "https://cran.rstudio.com/"))
modulesInstalled <- dir(modulePath)
dependencies <- SpaDES.core::reqdPkgs(module = modulesInstalled, modulePath = modulePath)
# scfm is actually a collection of modules... the modules are nested in folders
scfmModulePath <- file.path(modulePath, "scfm", "modules")
scfmModulesInstalled = dir(scfmModulePath)
dependencies <- append(dependencies,
SpaDES.core::reqdPkgs(module = scfmModulesInstalled,
modulePath = scfmModulePath) )
needed <- unique(unlist(dependencies, recursive = FALSE))
Require::Require(needed, require = FALSE, upgrade = "never")
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
install_github('PredictiveEcology/SpaDES')
Downloading GitHub repo PredictiveEcology/SpaDES@master
Error: HTTP error 403.
API rate limit exceeded for ###.###.##.###.
(...)
## ------------------------------------------------------------------------------------------------------------------------------------------------------------------
options("repos" = c(CRAN = "https://cran.rstudio.com"))
if (Sys.info()["sysname"] == "Linux" && grepl("Ubuntu", utils::osVersion)) {
.os.version <- strsplit(system("lsb_release -c", intern = TRUE), ":\t")[[1]][[2]]
.user.agent <- paste0(
"R/", getRversion(), " R (",
paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"]),
")"
)
options(repos = c(CRAN = paste0("https://packagemanager.rstudio.com/all/__linux__/",
.os.version, "/latest")))
options(HTTPUserAgent = .user.agent)
}