-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.R
190 lines (186 loc) · 8.27 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
# Importing libraries
library(shiny)
library(shinythemes)
library(fontawesome)
library(shinyWidgets)
library(igraph)
library(highcharter)
library(bslib)
source('helper.R')
ui <- page_navbar(
title = "Post-Columbine",
theme = bs_theme(
bootswatch = "cerulean",
navbar_bg = "#d3d3d3"
),
nav_spacer(),
nav_panel("Home",
fluidPage(
# Title for home tab
titlePanel("Overview of US School Shooting Incidents
Since the 99 Columbine High Massacre"),
hr(),
h5(strong("Critical Figures: Key Statistics in the Wake of the Columbine Tragedy"),
style = "font-size:16px;"),
# Value box
layout_columns(
value_box(
title = "Total Incident Count",
value = dim(dataset)[1],
theme = "bg-gradient-purple-cyan",
showcase = bsicons::bs_icon("hash"),
showcase_layout = "top right"
),
value_box(
title = "Students Endangered",
value = sum(dataset$enrollment),
theme = "bg-gradient-orange-indigo",
showcase = bsicons::bs_icon("people"),
showcase_layout = "top right"
),
value_box(
title = "Fatalities",
value = sum(dataset$killed),
theme = "bg-gradient-red-indigo",
showcase = bsicons::bs_icon("hospital"),
showcase_layout = "top right"
),
value_box(
title = "Injuries",
value = sum(dataset$injured),
theme = "bg-gradient-teal-indigo",
showcase = bsicons::bs_icon("bandaid"),
showcase_layout = "top right"
)
),
hr(),
# Adapt sidebar layout for the map visualization
sidebarLayout(
sidebarPanel(
# Define filter and options for the user
pickerInput("map_state",
tags$p(fa("filter", fill = "forestgreen"),
"State filter for visualisation"),
state_choiceVec, selected = state_choiceVec,
multiple = TRUE, options = list(`actions-box` = TRUE)),
checkboxGroupInput("school_filter",
tags$p(fa("filter", fill = "forestgreen"),
"School type filter"),
school_type_choiceVec, selected = school_type_choiceVec),
sliderInput("map_filter",
tags$p(fa("filter", fill = "forestgreen"),
"Select a time period for visualisation"),
min = 1999, max = 2023, value = c(1999, 2023), sep = "")
),
mainPanel(
highchartOutput("school_map", height = "100%")
)
),
hr(),
h5('Data Source: ',
a("The Washington Post",
href="https://github.com/washingtonpost/data-school-shootings"),
style = "font-size:16px;"),
h5('Charts and map are created using ',
a("Highcharter",
href="https://jkunst.com/highcharter/"),
'(a R wrapper for Highcharts)',
style = "font-size:16px;")
)
),
nav_panel("Timeline",
fluidPage(
titlePanel("An Alarming Timeline"),
hr(),
# Define highcharter output
highchartOutput("year_casualty", height = 485),
hr(),
h4("School shootings have been occurring every year since the 1999 Columbine massacre. The
number of casualties peaked in 2018 with a horrifying record of 95 casualties. The number
of incidents and casualties significantly reduced in 2020, which might be primarily due to
school closures during the pandemic. However, the number of incidents skyrocketed in 2021,
with a record-breaking 42 shooting incidents occurring that year.",
style = "color: #808080;font-size:15px;"),
hr(),
h5('Data Source: ',
a("The Washington Post",
href="https://github.com/washingtonpost/data-school-shootings"),
style = "font-size:16px;"),
h5('Charts and map are created using ',
a("Highcharter",
href="https://jkunst.com/highcharter/"),
'(a R wrapper for Highcharts)',
style = "font-size:16px;")
)
),
nav_panel("Shooter and Intention",
fluidPage(
titlePanel("Shooter And Intention"),
hr(),
# Use fluid row layout to put two plots side by side
fluidRow(
column(6, highchartOutput("shooter_age")),
column(6, highchartOutput("weapon_source"))
),
hr(),
h4("As depicted in the plot on the left, 58% of shooters with a known age fall
between 15 and 19 years old, followed by those aged 10 to 14, who constitute almost
20%. The plot on the right indicates that for those aged between 10 and 19, over
70% obtained their weapons from relatives. Thus, adults should be more vigilant and
limit minors' access to firearms. Conversely, the plot below reveals that over 55%
of shooting incidents were targeted. However, indiscriminate firing results in the
highest number of casualties, surpassing the combined total of other categories.",
style = "color: #808080;font-size:15px;"),
hr(),
fluidRow(
column(12, highchartOutput("shooter_intention"))
),
hr(),
h5('Data Source: ',
a("The Washington Post",
href="https://github.com/washingtonpost/data-school-shootings"),
style = "font-size:16px;"),
h5('Charts and map are created using ',
a("Highcharter",
href="https://jkunst.com/highcharter/"),
'(a R wrapper for Highcharts)',
style = "font-size:16px;")
)
),
nav_panel("School",
fluidPage(
titlePanel("School"),
hr(),
fluidRow(
column(5, highchartOutput("public_private")),
column(7, highchartOutput("school_type"))
),
hr(),
h4("As depicted in the pie chart on the left, nearly 94% of the shooting incidents
occurred in public schools. However, we must consider the fact that there are more
public schools than private schools. The bar chart on the right shows that over 60%
of the incidents happened in high schools, followed by elementary schools with 14.2%.
Nevertheless, local governments and schools should take more effective actions to
reduce the risk of school shootings.",
style = "color: #808080;font-size:15px;"),
hr(),
fluidRow(
column(6, highchartOutput("shooting_time")),
column(6, highchartOutput("enrolment_incidents"))
),
hr(),
h5('Data Source: ',
a("The Washington Post",
href="https://github.com/washingtonpost/data-school-shootings"),
style = "font-size:16px;"),
h5('Charts and map are created using ',
a("Highcharter",
href="https://jkunst.com/highcharter/"),
'(a R wrapper for Highcharts)',
style = "font-size:16px;")
)
),
nav_item(
input_dark_mode(id = "dark_mode", mode = "light")
)
)