-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathglobal.R
125 lines (112 loc) · 3.4 KB
/
global.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
options(conflicts.policy = list(warn = FALSE),
shiny.reactlog = TRUE)
shhh <- suppressPackageStartupMessages # It's a library, so shhh!
shhh(library(av))
shhh(library(bslib))
shhh(library(cptcity))
shhh(library(countrycode))
shhh(library(deSolve))
shhh(library(dplyr))
shhh(library(DT))
shhh(library(ggplot2))
shhh(library(htmltools))
shhh(library(latex2exp))
shhh(library(lattice))
shhh(library(latticeExtra))
shhh(library(leaflet))
shhh(library(maps))
shhh(library(markdown))
shhh(library(plotly))
shhh(library(purrr))
options("rgdal_show_exportToProj4_warnings"="none")
shhh(library(rasterVis))
shhh(library(readr))
shhh(library(readxl))
shhh(library(writexl))
shhh(library(sf)) # classes and functions for vector data
shhh(library(shiny))
shhh(library(shinyBS))
shhh(library(shinyalert))
shhh(library(shinybusy))
shhh(library(shinyhelper))
shhh(library(shinyjs))
shhh(library(shinyvalidate))
shhh(library(shinyWidgets))
shhh(library(sp))
shhh(library(stringr))
shhh(library(terra, warn.conflicts=FALSE)) # suppressWarnings(suppressMessages(library(terra)))
shhh(library(tidyverse))
shhh(library(tinytex))
shhh(library(here))
shhh(library(geodata))
here::i_am("global.R")
source("R/cropBaseRasterHaxby.R")
source("R/makePlots.R")
source("R/plotOptionsMenu.R")
source("R/rasterBasePlot.R")
source("R/rasterCropSeedPlot.R")
source("R/rasterCumulativePlot.R")
source("R/rasterLeafletPlots.R")
#source("R/rasterSimulation.R")
source("R/rasterSimulation_DA.R")
source("R/rasterStack.R")
source("R/WorldPopPlots.R")
options(scipen = 999)
population <- read_excel("misc/population.xlsx", 1)
shortlist <- filter(population, shortList == "TRUE")
epiparms <- read_excel("misc/epiparms.xlsx", 1)
### List of countries that need "the" prepended to their name
prependList <- c("Czech Republic",
"Democratic Republic of Congo",
"Gambia",
"Netherlands")
fieldsMandatory <- c("selectedCountry", "seedData")
valueRange <- c(0, 5, 10, 25, 50, 100, 250, 1000, 10000)
ramp <- c('#FFFFFF',
'#D0D8FB',
'#BAC5F7',
'#8FA1F1',
'#617AEC',
'#0027E0',
'#1965F0',
'#0C81F8',
'#18AFFF',
'#31BEFF',
'#43CAFF',
'#60E1F0',
'#69EBE1',
'#7BEBC8',
'#8AECAE',
'#ACF5A8',
'#CDFFA2',
'#DFF58D',
'#F0EC78',
'#F7D767',
'#FFBD56',
'#FFA044',
'#EE4F4D')
pal <- colorRampPalette(ramp)
colorPalette <- colorBin(pal(9)[-1], domain = valueRange, bins = valueRange)
highlightDrop <- function(menu) {
tagList(
menu,
span(class = "dropDown")
)
}
#--------------------------------------------------------------------#
# Helper function to open different files based on their format #
#--------------------------------------------------------------------#
openDataFile <- function(datafile) {
ext <- tools::file_ext(datafile$name)
ext <- tolower(ext)
switch(ext,
csv = read_csv(datafile$datapath, show_col_types = FALSE),
xls = read_xls(datafile$datapath),
xlsx = read_xlsx(datafile$datapath),
txt = read_tsv(datafile$datapath, show_col_types = FALSE),
validate("Improper file format.")
)
}
appCSS <- ".mandatory_star {color: red;}"
appCSS <- ".invisible {display:none;}"
appCSS <- ".dropDown:hover {color:ADD8E6;background-color: #000000}"