-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.R
147 lines (111 loc) · 4.43 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# ---------------------------------------------------------
# This is the global file.
# Use it to store functions, library calls, source files etc.
# Moving these out of the server file and into here improves performance
# The global file is run only once when the app launches and stays consistent
# across users whereas the server and UI files are constantly interacting and
# responsive to user input.
#
# ---------------------------------------------------------
# message("Sourcing global")
# Library calls ----------------------------------------------------------------
shhh <- suppressPackageStartupMessages # It's a library, so shhh!
shhh(library(shiny))
shhh(library(shinyjs))
shhh(library(tools))
shhh(library(testthat))
shhh(library(stringr))
shhh(library(shinydashboard))
shhh(library(shinyWidgets))
shhh(library(shinyGovstyle))
shhh(library(shinytitle))
shhh(library(dplyr))
shhh(library(ggplot2))
shhh(library(DT))
shhh(library(xfun))
shhh(library(metathis))
shhh(library(shinyalert))
shhh(library(shinytest2))
shhh(library(rstudioapi))
shhh(library(bslib))
shhh(library(dfeshiny))
shhh(library(ggiraph))
shhh(library(readxl))
# shhh(library(openxlsx))
shhh(library(snakecase))
shhh(library(tidyr))
shhh(library(shinycssloaders))
# shhh(library(shinya11y))
shhh(library(reactable))
# Functions --------------------------------------------------------------------
# This line enables bookmarking such that input choices are shown in the url.
enableBookmarking("url")
# Rounding -------------------------------------
round2 <- function(x, n) {
posneg <- sign(x)
z <- abs(x) * 10^n
z <- z + 0.5 + sqrt(.Machine$double.eps)
z <- trunc(z)
z <- z / 10^n
z * posneg
}
# Function defined for not in -------------------------------------
`%not_in%` <- purrr::negate(`%in%`)
# Source scripts ---------------------------------------------------------------
# Source any scripts here. Scripts may be needed to process data before it gets
# to the server file.
# It's best to do this here instead of the server file, to improve performance.
# source("R/filename.r")
# appLoadingCSS ----------------------------------------------------------------
# Set up loading screen
appLoadingCSS <- "
#loading-content {
position: absolute;
background: #000000;
opacity: 0.9;
z-index: 100;
left: 0;
right: 0;
height: 100%;
text-align: center;
color: #FFFFFF;
}
"
site_title <- "16-18 Ready Reckoner"
# the following two links are for the template. can update to ours if they are needed/set up. will need to uncomment out the beta banner code in the ui script
site_primary <- "https://department-for-education.shinyapps.io/dfe-shiny-template/"
# site_overflow <- "https://department-for-education.shinyapps.io/dfe-shiny-template-overflow/"
# We can add further mirrors where necessary. Each one can generally handle
# about 2,500 users simultaneously
sites_list <- c(site_primary)
# sites_list <- c(site_primary, site_overflow)
# Update this with your parent
# publication name (e.g. the EES publication)
ees_pub_name <- "A level and other 16 to 18 results"
# Update with parent publication link
ees_publication <- "https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results"
google_analytics_key <- "72QXVY0V75"
source("R/read_data.R")
# -----------------------------------------------------------------------------------------------------------------------------
# ---- read in the ready reckoner data from the Excel spreadsheet ----
# -----------------------------------------------------------------------------------------------------------------------------
data <- func_read_multiplesheets("data/2024U_l3va_step5_outputs_Rversion_redacted.xlsx")
template_data <- read.csv("data/pupil_upload_template.csv", check.names = FALSE)
data$qualid_lookup <- data$qualid_lookup %>%
mutate(cohort_code = as.character(cohort_code))
# -----------------------------------------------------------------------------------------------------------------------------
# ---- other ----
# -----------------------------------------------------------------------------------------------------------------------------
expandable <- function(inputId, label, contents) {
govDetails <- shiny::tags$details(
class = "govuk-details", id = inputId,
shiny::tags$summary(
class = "govuk-details__summary",
shiny::tags$span(
class = "govuk-details__summary-text",
label
)
),
shiny::tags$div(contents)
)
}