-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.R
84 lines (72 loc) · 2.5 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
library(data.table)
library(shiny)
library(ggplot2)
library(ggiraph)
library(DT)
library(dplyr)
library(jsonlite)
library(openxlsx)
library(tidyverse)
library(glue)
library(shinyalert)
library(httr)
# TODO: use RENV!
if (!requireNamespace("cleaned", quietly = TRUE)) {
remotes::install_github("CIAT/cleaned@cleaned_v0.6.0")
}
library(cleaned)
options(
spinner.color = "#005275",
spinner.color.background = "white",
spinner.type = 3,
# Set the maximum file upload size globally to 20MB
shiny.maxRequestSize = 20 * 1024 ^ 2
)
# Auth0 info
auth0_info <- auth0::auth0_info()
# Set locale to English for formatting
original_locale <- Sys.getlocale("LC_TIME") # Store the current locale
Sys.setlocale("LC_TIME", "C") # Set to C locale for English
# TODO: Once the PR is accepted, switch back to the official CIAT repository
# by changing the URL and branch references to:
# URL to https://github.com/CIAT/cleaned
# Branch/Tag to cleaned_v0.6.0
# Ideally, user {renv} package to manage the package versions
# List of all parameter tables
parameters_db_names <- c(
"lkp_climate", "lkp_climate2", "lkp_croplandsystem", "lkp_feeditem",
"lkp_feedtype", "lkp_grassinputlevel", "lkp_grasslandman", "lkp_landcover",
"lkp_livetype", "lkp_manureman", "lkp_organicmatter", "lkp_orgfertilizer",
"lkp_region", "lkp_slope", "lkp_soil", "lkp_tillageregime"
)
# Read static parameters directory and files
ghg_ipcc_data <- fromJSON(
system.file("extdata", "ghg_parameters.json", package = "cleaned"),
flatten = TRUE
)
stock_change_para <- fromJSON(
system.file("extdata", "stock_change_parameters.json", package = "cleaned"),
flatten = TRUE
)
energy_parameters <- fromJSON(
system.file("extdata", "energy_parameters.json", package = "cleaned"),
flatten = TRUE
)
primary_excel <- "www/ReadMe.xlsx"
graphs_desc <- readxl::read_excel(
path = "data/iCLEANED - Graphs Information.xlsx",
sheet = 2
)
# Plots default values
max_feed_items <- max_seasons <- 20
# most recent file in data/objects
files_info <- file.info(list.files(file.path("data", "study_objects"), full.names = TRUE))
# Get the most recent file name
most_recent_file <- basename(rownames(files_info)[which.max(files_info$mtime)])
# Get the last modification date
last_modification_date <- format(
files_info$mtime[which.max(files_info$mtime)], "%B %d, %Y"
)
# Stat Counter project and security key (.Renviron)
sc_project <- Sys.getenv("SC_PROJECT")
sc_security <- Sys.getenv("SC_SECURITY")