-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.R
54 lines (41 loc) · 1.88 KB
/
setup.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
# Run this script before working with this project. It handles package installation and loading
# and sources local functions.
#
# A. check for CRAN available packages - install missing
# B. check for GITHUB available packages - install missing
# C. install any others
# D. load packages from library
# E. set the working directory
# F. source each file in subdir 'functions'
installed = rownames(installed.packages())
cran_packages = c("remotes", "rlang", "here", "httr", "R6", "xml2", "rerddap", "sf", "stars",
"rnaturalearth", "rnaturalearthdata", "dataRetrieval", "ncdf4", "ggplot2",
"scales", "tidyr", "readr", "dplyr", "stringr", "purrr", "magrittr", "corrr",
"patchwork", "ggOceanMaps", "ggside", "smoothr", "moments")
ix = (cran_packages %in% installed)
for (package in cran_packages[!ix]) {
install.packages(package)
}
github_packages = c("cofbb" = "BigelowLab",
"stsaav" = "BigelowLab",
"wdspaleo" = "BigelowLab",
"ghcnd" = "BigelowLab",
"ersst" = "BigelowLab")
ix = names(github_packages) %in% installed
for (package in names(github_packages[!ix])) {
remotes::install_github(sprintf("%s/%s", github_packages[package], package))
}
if (!("rnaturalearthhires" %in% installed)) {
install.packages("rnaturalearthhires", repos = "http://packages.ropensci.org", type = "source")
}
suppressPackageStartupMessages({
for (package in cran_packages) library(package, character.only = TRUE)
for (package in names(github_packages)) library(package, character.only = TRUE)
library(rnaturalearthhires)
})
here::i_am("setup.R")
# setting the base map - me no like - better if it were an argument)
options(ggOceanMaps.userpath = here::here("data", "bathy", "gebco-gom.tif"))
for (f in list.files(here("functions"), pattern = "^.*\\.R$", full.names = TRUE)){
source(f)
}