-
Notifications
You must be signed in to change notification settings - Fork 5
/
ui.R
442 lines (354 loc) · 16.2 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
#
# This is the user-interface definition of a Shiny web application. You can
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(plotly)
library(shiny)
library(shinydashboard)
library(shinyjs)
inputUserid <- function(inputId, value='') {
# print(paste(inputId, "=", value))
tagList(
singleton(tags$head(tags$script(src = "js/md5.js", type='text/javascript'))),
singleton(tags$head(tags$script(src = "js/shinyBindings.js", type='text/javascript'))),
tags$body(onload="setvalues()"),
tags$input(id = inputId, class = "userid", value=as.character(value), type="text", style="display:none;")
)
}
inputIp <- function(inputId, value=''){
tagList(
singleton(tags$head(tags$script(src = "js/md5.js", type='text/javascript'))),
singleton(tags$head(tags$script(src = "js/shinyBindings.js", type='text/javascript'))),
tags$body(onload="setvalues()"),
tags$input(id = inputId, class = "ipaddr", value=as.character(value), type="text", style="display:none;")
)
}
dashboardPage(
# tags$main-header(
# tags$link(rel = "stylesheet", type = "text/css", href = "NJcrash.css"),
# tags$link(rel = "stylesheet", type = "text/css", href = "icon/css/font-awesome.min.css"),
# tags$link(rel = "stylesheet", type = "text/css", href = "https://file.myfontastic.com/M27ntRiDvYmgVMSDV8e5Qj/icons.css")
# ),
skin="yellow",
#This is the header of the dashboard
dashboardHeader(
# title = list(icon("dashboard"),"NJ Crash Overview"),
title=tags$a(href="http://codeforprinceton.org/",tags$i(class="icon-codeforprinceton-3", style="font-size:50px;", onMouseOver="this.style.color='rgb(34, 45, 50)'",
onMouseOut="this.style.color='rgb(255, 255, 255)'")),
# Dynamic Message
# dropdownMenuOutput("messageMenu"),
#Disable Header Bar
disable = F,
# THis is the dropdown menu
dropdownMenu(
icon = icon("users"),
type = "message",
messageItem(
icon=icon("user"),
from = "Jiahuan KANG",
message = " "
),
messageItem(
icon=icon("user"),
from = "Manbir Mohindru",
message = " "
),
messageItem(
icon=icon("user"),
from = "CHris Hefele",
message = "New member"
),
messageItem(
icon=icon("user"),
from = "Paz Tarrio",
message = "New member"
),
messageItem(
icon=icon("user"),
from = "Deva Prasad",
message = "New member"
),
messageItem(
icon=icon("user"),
from = "Vijay Appasamy",
message = "New member"
),
messageItem(
icon=icon("user"),
from = "Ashok Khandelwhl",
message = "New member"
),
messageItem(
icon=icon("user"),
from = "Fred Kelly",
message = "New member"
)
),
dropdownMenu(
icon = icon("tasks"),
type = "tasks",
taskItem(
"Create UI",
value=10,
color="green"
# href = ""
),
taskItem(
"Fix data issues",
value=50,
color="aqua"
# href = ""
),
taskItem(
"Create basic statistics",
value=20,
color="yellow"
# href = ""
),
taskItem(
"Create data visulizations",
value=30,
color="aqua"
# href = ""
),
taskItem(
"Write up stories for data and visualizations",
value=35,
color="red"
# href = ""
)
)
# dropdownMenu(
# icon = icon("tasks"),
# type = "notification",
# notificationItem("text", icon = shiny::icon("warning"), status = "success",
# href = NULL)
#
# )
),
# This is the side bar of the dashboard
dashboardSidebar(
# disable=TRUE,
# sideBarMini=TRUE,
#
# useShinyjs(),
# actionButton("showSidebar", "Show sidebar"),
# actionButton("hideSidebar", "Hide sidebar"),
#Counter
inputIp("ipid"),
inputUserid("fingerprint"),
#search form server side code: input$searchText and input$searchButton
sidebarSearchForm("searchText", "searchButton", label = "Search...",
icon = shiny::icon("search")),
sidebarMenu(id="sidebarMenu",
menuItem("Control Panel",tabName = "Dashboard",icon = icon("dashboard"),fluidRow(width=12,
sliderInput("year", label = "Select Year:",min = 2001, max = 2014, value = 2001, sep="", ticks=TRUE, animate=TRUE)
# hr(),
# selectInput("trendtype", label = "What are you interested in?",
# choices = list("NJ Accidents by Gender" = 1, "NJ Accidents by Day of Week" = 2, "NJ Accidents by ..." = 3),
# selected = 1)
)),
menuItem("Home",tabName = "Home",icon = icon("home")),
menuItem("Basic Statistics",tabName = "Basic_Statistics",icon = icon("info-circle")),
menuItem("Accidents", tabName = "accidents", icon=icon("th"),badgeLabel = "updating", badgeColor = "green"),
menuItem("Driver", tabName = "driver", icon=icon("th"),badgeLabel = "updating", badgeColor = "green"),
menuItem("Code for Princeton",icon=icon("th"),href="http://codeforprinceton.org/",newtab =F),
menuItem("Github",icon=icon("th"),href="https://github.com/codeforprinceton/uncrash",newtab = F)
),
conditionalPanel("input.sidebarMenu == 'Home'",
class = "shiny-input-container",
sliderInput("graph_slider", "Graphs slider:", min=1, max=10, value=2)
),
conditionalPanel("input.sidebarMenu == 'accidents'",
class = "shiny-input-container",
sliderInput("table_slider", "Table slider:", min=1, max=10, value=3)
)
),
# This is the body of Dashboard
dashboardBody(
useShinyjs(),
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "NJcrash.css"),
tags$link(rel = "stylesheet", type = "text/css", href = "icon/css/font-awesome.min.css"),
tags$link(rel = "stylesheet", type = "text/css", href = "https://file.myfontastic.com/M27ntRiDvYmgVMSDV8e5Qj/icons.css")
),
tabItems(
#tab 0
tabItem(tabName="select" ),
#tab 1
tabItem(tabName="Home",
fluidRow(style="margin-top:50px;",
box(width=12, collapsible = TRUE, title = list(icon("dashboard"),"NJ Crash Overview"),
tabBox(
id="tabset1",
width = "100%",
tabPanel("NJ Accident by Gender",collapsible=TRUE,solidHeader=TRUE,status="warning",
# fluidRow(width=3, selectInput("trendtype", label = "What are you interested in?",
# choices = list("NJ Accidents by Gender" = 1, "NJ Accidents by Day of Week" = 2, "NJ Accidents by ..." = 3),
# selected = 1)),
#
plotlyOutput("trendline", width = "100%", height = "100%"),width="1280px",height="500px")
,
tabPanel("NJ Accident by Day of Week",collapsible=TRUE,solidHeader=TRUE,status="warning",plotlyOutput("trendline2", width = "100%", height = "100%"),width="1280px",height="500px")
,
#tabPanel("Pie chart",collapsible=TRUE,solidHeader=TRUE,status="warning",plotlyOutput("pie", width = "auto", height = "500px"),width="1280px",height="500px"),
tabPanel("Bar chart",collapsible=TRUE,solidHeader=TRUE,status="warning",plotlyOutput("bar", width = "100%", height = "100%"),width="1280px",height="500px")
)
)),
fluidRow(
box(width=12,status = "warning", title=list(tags$i(class="fa fa-grav"),"What we discovered?"),collapsible = TRUE,
hr(),
h4("From year 2001 till 2014, 9,058 people were killed and 1,386,636 people were injured in 4,062,688 car accidents in the state of NJ,
that is, on average, 647 people killed and 99,045 people injured every year on NJ roads.
"),
p("The Uncrash team took a look to the traffic accidents in NJ from 2001 to 2014.
The data was analyzed in different ways to look for patterns that would help us to reach conclusions that eventually would lead to raise awareness about the factors more frequently associated with traffic crashes to avoid/be mindful of those and hopefully diminish the incidence of car crashes.
The data analyzed identified geographical points with higher incidence of crashes. Those point coincide most of the times with street intersections.
Males are more frequently involved in car crashes than females.
Younger population are more frequently involved in car crashes involving only one car
The team propose different ways to visualize these data and different approaches to look at the data from statewide information to street-wide information
"),
tags$li("1- Big areas - Heatmaps showing areas of high accident frequency"),
tags$li("2- Accident density map focusing on Route 1. It is the largest contribute to accidents in our local area."),
tags$li("3- Street level maps showing precise locations of high incidence of crushes (i.e. clusters)")
,p("Between 2001 and 2014, the traffic crash that involved a higher number of cars in NJ was on Monmouth County, on August 27, 2003.")
)
)
,
fluidRow(
column(6, box(width=12,status = "success",collapsible = TRUE,collapsed = F,
plotlyOutput("pie", width = "auto", height = "auto"),
box(width = 12, status = "warning",
h4("County Accident"),
p("Accidents by County charts shows the porportion of accidents in NJ by County.
Of all the counties in NJ, Essex, Bergen, Middlesex county have the most accidents, which accounts to 1/3 of all accidents in NJ")
)
),
box(width = 12, status = "primary",
img(src="heatmap.png"),
box(width = 12, status = "warning",
h4("Accident Heat Map"),
p("This plot is a heatmap showing accident \"hot-spots\"
in the Princeton & West Windsor areas from 2001-2014.
US Route 1 (the long diagonal line near the
center of the image) and downtown Princeton
(the red cluster at the top of the map)
are the largest contributors to local accidents.
Local and residential streets are not.")
)
)
),
column(6,
box(width = 6, status = "primary",collapsible = TRUE,collapsed = F,
img(src="US1.png"),
box(width = 12, status = "warning",
h4("US Route 1 Chart"),
p("This plot shows the accident density on US Route 1
in the Princeton, NJ area (as derived from
NJ DOT accident data 2001-2014).
The major cross-streets are shown on the bottom;
the correspondence of the peaks with the cross streets
shows that most accidents occur at major intersections,
not *between* intersections.")
)
),
box(width = 6, status = "success",
img(src="NJ_Accdt.png"),
box(width = 12, status = "warning",
h4("Accidents in NJ"),
p("Each of the 7,000+ dots on this map represents a NJ
accident with a fatality during the
the pariod 2001-2014, The main highways
can be seen in the pattern of dots,
such as Routes 80 & Route 78 near the top of the plot,
the Garden State Parkway near the right,
Route 1 and the NJ Turnpike near the middle, and
the Atlantic City Expressway near the bottom.
")
)
)
)
),
# fluidRow(
# ),
# Add Approval box
fluidRow(
column(11," "),
column(1,
valueBoxOutput("approvalBox", width="5%"),
actionButton("count","Click")
# h5(textOutput("counter"))
# textOutput("testtext")
)
)
),
# tab 2
tabItem(tabName="Basic_Statistics",
h3("Basic Information and Statistics about NJ Crash Data", align="center"),
tags$hr(),
box(DT::dataTableOutput('tbl'),
status="warning",
title="Data field names and type ",
width=6,
collapsible=TRUE
)
),
#tab 3
tabItem(tabName="accidents",
h4("Accidents in Princeton Intersections"),
p("This street-level maps show the exact locations
of accidents in the Princeton/West-Windsor area
between 2001 and 2014. Each accident is represented
with a dot. If there were multiple accidents
at a specific location, the dots are aggregated
and the count shown within a larger circle.
When looking at this street-level detail, it's
clear that intersections along major roads
are the most frequent location for accdeints."),
fluidRow(
htmlOutput("frame")
)
),
# tab 4
tabItem(tabName="driver",
h2("Widgets tab content")
)
# # tab 4
# tabItem(tabName="Code for Princeton",
# h2("Widgets tab content")
#
# ),
#
# # tab 5
# tabItem(tabName="Github",
# h2("Widgets tab content")
#
# )
)
)
)
# sidebarLayout(
# sliderInput("year", label = h4("Select year:"),
# min = 2001, max = 2014, value = 2001, sep="", ticks=FALSE, animate=TRUE),
#
# plotlyOutput("trendline", width = "100%", height = 900)
# )
#
# ))
# sidebarLayout(
# sidebarPanel(
# sliderInput("year", label = h4("Select year:"),
# min = 2008, max = 2014, value = 2014, sep="", ticks=FALSE, animate=TRUE)
# )
# ,
# fluidRow(
# mainPanel(
# plotlyOutput("trendline", width = "100%", height = "100%")
# )
# )
# )
# Show a plot of the generated distribution