forked from CLIMtools/AraCLIM-V2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.R
executable file
·85 lines (69 loc) · 2.46 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
require(shiny) #warning for any modifications, a lot of things in here are hardcoded
require(shinydashboard) #if using new data/databases, please check lines 25, 31, 38, 42, and 59
require(shinyjs) #more errors might arise in the server.R file as well, please check it for other line numbers of interest
require(leaflet)
require(ggvis)
library(plyr)
require(dplyr)
library(RColorBrewer)
require(raster)
require(gstat)
require(rgdal)
require(Cairo)
library(sp)
library(htmltools)
# library(shinyauthr)
# dataframe that holds usernames, passwords and other user data
# user_base <- tibble::tibble(
# user = c("user1", "user2"),
# password = c("pass1", "pass2"),
# permissions = c("reviewer", "standard"),
# name = c("reviewer", "User Two")
# )
#this is useless both of these are just downloads or something useless. ALready read in different dataframes why waste processing power ????
#this is input of data files
readfile <- read.csv("data/Sorghum_Climates_updated.csv",row.names = NULL)
#still unknown what the purpose of this is
readfile2 <- read.csv("data/datadescriptionc.csv",row.names = NULL)
#actual table that is used for plotting (I believe)
FULL.val <-read.csv("data/SORGHUM_CLIMATES.csv")
#debug?
class(FULL.val)
#getting rid of NA
na.omit(FULL.val)
#reads in the category labels for each of the categories used in the input of the data files above
#MUST MATCH FULL.val csv FILE IN ORDER EXACTLY, ANY DEVIATION WILL RESULT IN ERROR
vlc <- read.delim("data/variable_label_categorybDirectSorg.txt", header = FALSE, sep = "\t")
#sets a new vars dataframe and categories dataframe
colnames(FULL.val) <- vlc[,2]
cats <- read.delim("data/categoriesb.txt", header = FALSE, sep = "\t")
vars <- vector("list",dim(cats)[1])
names(vars) <- cats$V1
n = dim(vlc)[1]
for(i in 1:n) {
c <- vlc[i,3]
l <- vlc[i,2]
if (is.null(vars[[c]])) {
vars[c] <- c(l)
}
else {
vars[[c]] <- c(vars[[c]], l)
}
}
# a data.frame
#IF MODIFYING FILES FROM EARLIER, YOU MUST CHANGE THE VALUES USED FOR FULL.val HERE. IT IS HARDCODED
#HARD CODED vvvvvvvv
FULL <- SpatialPointsDataFrame(FULL.val[,c("Longitude (degrees)", "Latitude (degrees)")], FULL.val[,1:307])#this was changed for Sorg
#HARD CODED ^^^^^^^^
#########
descriptiondataset <-read.csv("data/datadescriptionc.csv")
#defined datasets for use in the server.R file
#description dataset does not have a equals value?
datasets <- list(
'FULL'= FULL,
'cats'= vars,
'descriptiondataset'
)
baselayers <- list(
'FULL'='Esri.WorldImagery'
)