-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
375 lines (348 loc) · 13.8 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
shinyUI(dashboardPage(
# Header Section ####
dashboardHeader(title = "US Gun Violence"),
# Sidebar Section ####
dashboardSidebar(
## * Initial Menu Tabs ####
sidebarMenu(
menuItem("A Shiny App by Theodore Cheek",
icon = NULL,
href = "https://www.linkedin.com/in/theodorecheek/"),
menuItem('State Dashboard',
tabName = 'Breakdown',
icon = icon("map")),
menuItem(
'National Dashboard',
tabName = 'Involvement',
icon = icon('users')
),
menuItem(
'Data Reporting',
tabName = "News",
icon = icon("newspaper")
)
),
## * Daterange Slider ####
sliderInput(
"daterange",
"Select a Date Range",
min = as.Date("2013-01-01"),
max = as.Date("2018-03-01"),
value = c(as.Date("2014-01-01"), as.Date("2018-03-01")),
timeFormat = "%b %Y"
),
## * Characteristic Drop-down ####
selectizeInput("targ.char",
"Select Target Characteristic",
targ.range),
br(),
## * Sources Sidebar ####
sidebarMenu(
menuItem(
"Sources",
icon = icon("folder-open"),
menuSubItem(
"Github R Source Code",
icon = icon("file-code-o"),
href = "https://github.com/BaroqBard/Gun_Violence_Analysis"
),
menuSubItem(
"Kaggle Web-Scraped Data",
icon = icon("list-alt"),
href = "https://www.kaggle.com/jameslko/gun-violence-data"
),
menuSubItem(
"Gun Violence Archive",
icon = icon("list-alt"),
href = "https://www.gunviolencearchive.org/"
),
menuSubItem(
"Population Data",
icon = icon("list-alt"),
href = "https://worldpopulationreview.com/states"
),
menuSubItem(
"Gun Laws by State 2020",
icon = icon("list-alt"),
href = "https://worldpopulationreview.com/state-rankings/gun-laws-by-state"
)
),
menuItem(
"Blog Post - Using this Website",
icon = icon("blog"),
href = "https://nycdatascience.com/blog/student-works/us-gun-violence/"
),
menuItem(
"~ Theodore Cheek LinkedIn ~",
icon = icon("linkedin"),
href = "https://www.linkedin.com/in/theodorecheek/"
)
)
),
# Body Section ####
dashboardBody(tabItems(
tabItem(tabName = "Breakdown",
tabsetPanel(
tabPanel(
## * State Dashboard ####
"Geographical Overview",
fluidRow(
box(
title = "Incident Density Tracker by State",
solidHeader = T,
status = "primary",
htmlOutput("gun.map"),
footer = "Hover for state-by-state incident stats, scaled below",
width = 12
)
),
fluidRow(
box(
title = "Choose a Scale:",
solidHeader = T,
"Select whether incidents are displayed per capita or
by total",
status = "success",
radioButtons(
inputId = "pop_scale",
label = NULL,
choices = c("Per Capita x 100,000" = "percap",
"Total Incidents" = "identity")
),
width = 3
),
infoBoxOutput("dashMax"),
infoBoxOutput("dashMeanGuns"),
infoBoxOutput("dashMaxInj"),
infoBoxOutput("dashMaxKill")
)
),
tabPanel(## * Legal Analysis ####
"Legal Analysis",
fluidRow(
box(
title = "Relationship between State Regulations & Incident Fallout",
solidHeader = T,
status = "primary",
htmlOutput("dash.law"),
footer = "The bubble color represents the density of
statewide restrictions on Weaponry. Filter these
below. Scroll Up to Zoom Out, Scroll Down to
Zoom in. Click & Drag to Pan, Right-click to Reset",
width = 12
)
),
fluidRow(
box(
title = "State Weapon Regulations",
solidHeader = T,
status = "success",
checkboxGroupInput(
"legal.parameter",
"Select Included Weapon Restrictions:",
c(
"Firearm Registration" = "Fire",
"Carry Permit" = "Carry",
"Purchase Permit" = "Purchase",
"Open Carry Restricted" = "Open"
),
selected = c("Fire",
"Carry",
"Purchase",
"Open")
),
width = 6
),
box(
title = "Select Secondary Parameter & Scaling",
solidHeader = T,
"Secondary Characteristic: ",
status = "warning",
selectizeInput(
inputId = "state.cat",
label = NULL,
choices = c("Injured",
"Killed",
"Guns")
),
"Display scale: ",
radioButtons(
inputId = "state.scale",
label = NULL,
choices = c("Per Capita x 100,000" = "percap",
"Total Incidents" = "identity")
),
width = 6
)#,
# box(
# title = "Select Display Mode",
# solidHeader = T,
# status = "warning",
# "Select graph color value",
# radioButtons(
# inputId = "display.mode",
# label = NULL,
# choices = c(
# "Weaponry Restrictions" = "Restrictions",
# "Difference from Mean" = "Difference"
# )
# ),
# # "Include ONLY States with Selected Restrictions",
# # checkboxInput(
# # inputId = "focus.restriction",
# # label = "Restrict Selection",
# # value = FALSE
# # ),
# width = 4
# )
),
fluidRow(
box(
title = "Searchable Legal & Incidental State Data",
solidHeader = T,
status = "info",
DT::dataTableOutput("dashtable"),
width = 12
)
))
)),
# WHO is involved? Details of Victims & Suspects
tabItem(tabName = "Involvement",
tabsetPanel(
## * Participant Data ####
tabPanel(
"Participant Overview",
# put the boxes here
fluidRow(
box(
title = "Age Distribution of Incident Participants",
status = "primary",
solidHeader = T,
plotlyOutput("part.age"),
width = 12
)
),
fluidRow(
box(
title = "Proportional Age Involvement",
status = "info",
solidHeader = T,
plotOutput("part.agegroup",
width = "100%",
height = "250px"),
width = 6
),
valueBoxOutput("vic.age", width = 3),
valueBoxOutput("sus.age", width = 3),
infoBoxOutput("sus.outcome", width = 6),
infoBoxOutput("vic.outcome", width = 6)
),
fluidRow(
box(
title = "Subsequent Status of Participants (Log Scale)",
status = "success",
solidHeader = T,
plotlyOutput("part.status"),
width = 12
)
)
),
## * Coincident Details ####
tabPanel(
"Coincidental Characteristics",
fluidRow(
box(
title = "Visual Record of Incidents Over Time",
status = "primary",
solidHeader = T,
plotlyOutput("natl.timeline"),
width = 12
)
),
fluidRow(
box(
title = "Primary Coincidence",
status = "warning",
solidHeader = T,
plotOutput("natl.coinc1",
height = "160px"),
width = 4
),
box(
title = "Secondary Coincidence",
status = "warning",
solidHeader = T,
plotOutput("natl.coinc2",
height = "160px"),
width = 4
),
box(
title = "Tertiary Coincidence",
status = "warning",
solidHeader = T,
plotOutput("natl.coinc3",
height = "160px"),
width = 4
)
),
fluidRow(
box(
title = "Concurrent Incident Characteristics",
status = "info",
solidHeader = T,
"The following characteristics represent the most
common, coincident characteristics, featured
alongside your target characteristic",
DT::dataTableOutput("coincident.table"),
width = 6
),
box(
title = "Weaponry Most Often Reported",
status = "info",
solidHeader = T,
"The following weapons are most often recognized
in reports of gun violence per your selection.
This section includes BOTH Guns & Ammunition",
DT::dataTableOutput("weapons.table"),
width = 6
)
)
)
)),
tabItem(tabName = "News",
tabsetPanel(
## * Filtered, Searchable Data ####
tabPanel("Filtered, Searchable Data",
fluidRow(
box(
title = "Select Details from the Filtered Dataset",
status = "primary",
solidHeader = T,
"Here you will find searchable, selected notes
from the dataset that has been filtered according
to your target characteristic. In order to save
this selection, use the buttons below to capture
the information",
DT::dataTableOutput("detailtable"),
width = 12
)
)),
## * Original Unfiltered Dataset
tabPanel("Original, Unfiltered Dataset",
fluidRow(
box(
title = "Original, Unfiltered Incident Data",
status = "warning",
solidHeader = T,
"Below you may find the raw, unfiltered dataset,
which I acquired from Kaggle. Feel free to peruse it
here, however, if you wish for further documentation,
please navigate to the Kaggle link in the Sources
drop-down",
DT::dataTableOutput("guntable"),
width = 12
)
))
))
))
))