-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathheader.R
79 lines (71 loc) · 2.85 KB
/
header.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
# Copyright 2018 Province of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
## Install the packages we will need from CRAN:
package_list <- c("dplyr", "sp", "ggplot2", "stringr", #"zoo"
"grid", "scales", #ggmap",
"devtools", "rvest", "RColorBrewer", "mapview",
"purrr", "sf", "gridExtra", "bcmaps", "scales", "forcats",
"rmapshaper", "janitor", "readr", "cowplot", "glue", "lubridate")
package_new <- package_list[!(package_list %in% installed.packages()[,"Package"])]
if(length(package_new)) install.packages(package_new)
## Install the packages we will need from GitHub:
package_github <- c(bcgov = "bcgroundwater", bcgov = "envreportutils",
bcgov = "bcmaps", bcgov="bcdata", thomasp85 = "patchwork")
package_new <- package_github[!(package_github %in% installed.packages()[,"Package"])]
if(length(package_new)) {
devtools::install_github(paste(names(package_new), package_new, sep = "/"))
}
## ggmap needs to be installed from GitHub, using the `tidyup` branch
# from a known working commit https://github.com/dkahle/ggmap/tree/3ffc51b965709162dbaa62b3baa6106f59eba27b.
# See https://github.com/dkahle/ggmap/issues/51
if (!"ggmap" %in% installed.packages()[, "Package"] ||
utils::packageVersion("ggmap") < package_version("2.7.902")) {
devtools::install_github("dkahle/ggmap", ref = "3ffc51b965709162")
}
## Load required packages
library(sf)
library(dplyr)
library(purrr)
library(tidyr)
library(bcgroundwater)
library(sp)
#library(rgdal)
library(rvest)
library(stringr)
library(bcmaps)
library(ggplot2)
library(grid)
library(RColorBrewer)
library(scales)
library(ggmap)
library(forcats)
library(rmapshaper)
library(gridExtra)
library(envreportutils)
library(janitor)
library(readr)
library(glue)
library(patchwork)
library(cowplot)
library(leaflet)
#library(webshot)
library(htmlwidgets)
library(knitr)
library(mapview)
## Create project directories
if (!exists("tmp")) dir.create("tmp", showWarnings = FALSE)
if (!exists("out")) dir.create("out", showWarnings = FALSE)
if (!exists("out/figs")) dir.create("out/figs", showWarnings = FALSE)
if (!exists("leaflet_map/well_plots")) dir.create("leaflet_map/well_plots", showWarnings = FALSE)
if (!exists("leaflet_map/regional_plots")) dir.create("leaflet_map/regional_plots", showWarnings = FALSE)
## Invisible header object
.header_sourced <- TRUE