-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.R
222 lines (172 loc) · 10.5 KB
/
ui.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
packages <- c("shiny", "tidyverse", "stringr", "shinythemes", "shinyWidgets", "DT")
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
install.packages(setdiff(packages, rownames(installed.packages())), repos = "http://cran.us.r-project.org")
}
library(tidyverse)
library(shiny)
library(stringr)
library(shinythemes)
library(shinyWidgets)
library(DT)
# Loading data that was compiled by the script 01_combining_data.R
# The output .rds files from the output_data folder were moved into this folder where the ui.R and server.R scripts reside
countries <- readRDS("output_data/consolidated_long.rds")
regions <- readRDS("output_data/regional_long.rds")
nm <- readRDS("output_data/nm.rds")
cate <- readRDS("output_data/categories.rds")
## Prepping lists for pull down menu options
countries_list <- unique(countries$`Foreign State`)
countries_region <- unique(countries$area)
visa_type <- unique(countries$type)
nm <- dplyr::rename(nm, Country=`Foreign State of Chargeability or Place of Birth`)
countries_list_nm <- unique(nm$Country)
visa_type_nm <- unique(nm$type)
specific_categories <- unique(cate$TypeOf)
shinyUI(fluidPage(theme=shinytheme("flatly"),
# Inserting the Washington Post Investigative logo
list(tags$head(HTML('<link rel="icon", href="https://avatars3.githubusercontent.com/u/29076131?s=30&v=4",
type="image/png" />'))),
div(style="padding: 1px 0px; width: '100%'",
titlePanel(
title="", windowTitle="Visas explorer"
)
),
navbarPage(
title=div(HTML("<img src='https://avatars3.githubusercontent.com/u/29076131?s=30&v=4' hspace='5'>"), "Visas Explorer"),
tabPanel("Countries",
sidebarLayout(
sidebarPanel(
h4("Select Country"),
pickerInput(
inputId = "CountryPicker",
label = NULL,
choices = countries_list,
selected = "Afghanistan",
options = list(
`actions-box` = TRUE,
size = 9,
`selected-text-format` = "count > 3"
),
multiple = TRUE
),
h4("Select Visa Type"),
pickerInput(
inputId = "VisaPicker",
label = NULL,
choices = visa_type,
selected = visa_type,
options = list(
`actions-box` = TRUE,
size = 9,
`selected-text-format` = "count > 3"
),
multiple = TRUE
),
p("Note: 2018 figure is projected number based on 8 months of data")
),
mainPanel(
tabsetPanel(
tabPanel("Chart",
plotOutput("top_chart", height="600px")
),
tabPanel("Table",
dataTableOutput("top_table")
))))
),
tabPanel("Region",
sidebarLayout(
sidebarPanel(
h4("Select Region"),
pickerInput(
inputId = "RegionPicker",
label = NULL,
choices = countries_region,
selected = "Asia",
options = list(
`actions-box` = TRUE,
size = 9,
`selected-text-format` = "count > 3"
),
multiple = TRUE
),
h4("Select Visa Type"),
pickerInput(
inputId = "VisaPicker2",
label = NULL,
choices = visa_type,
selected = visa_type,
options = list(
`actions-box` = TRUE,
size = 9,
`selected-text-format` = "count > 3"
),
multiple = TRUE
),
p("Note: 2018 figure is projected number based on 8 months of data"),
p("* Countries are categorized into regions defined by Department of State. For example, Kosovo, Kyrgyzstan, Tajikistan, Turkmenistan, and Uzbekistan are considered by State as part of Europe instead of Asia.")
),
mainPanel(
tabsetPanel(
tabPanel("Chart",
plotOutput("region_chart", height="600px")
),
tabPanel("Table",
dataTableOutput("region_table")
))))
),
tabPanel("October - May",
sidebarLayout(
sidebarPanel(
h4("Select Country"),
pickerInput(
inputId = "CountryPickerNM",
label = NULL,
choices = countries_list_nm,
selected = "Afghanistan",
options = list(
`actions-box` = TRUE,
size = 9,
`selected-text-format` = "count > 3"
),
multiple = TRUE
),
h4("Select Visa Type"),
pickerInput(
inputId = "VisaPicker3",
label = NULL,
choices = visa_type_nm,
selected = visa_type_nm,
options = list(
`actions-box` = TRUE,
size = 9,
`selected-text-format` = "count > 3"
),
multiple = TRUE
)
),
mainPanel(
tabsetPanel(
tabPanel("Chart",
plotOutput("nm_chart", height="600px")
),
tabPanel("Table",
dataTableOutput("nm_table")
))))
),
tabPanel("Calculations",
mainPanel(
h2("Analysis (2018 is projection based on 8 months of data)"),
tabsetPanel(
tabPanel("Countries - Percent change",
dataTableOutput("sum_table1", height="600px")
),
tabPanel("Visa types - Percent change",
dataTableOutput("visa_types1", height="600px")
),
tabPanel("Visa types - All years",
dataTableOutput("visa_types3", height="600px")
)
))
)
)
))