-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
137 lines (129 loc) · 6.34 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
#
# This is the user interface for our shiny web app. It is based upon shinydashboard package
# Ideas of vizualisation
# - Car accident distribution
# - Region
#
# Sources:
# https://shiny.rstudio.com/articles/tag-glossary.html
# https://stackoverflow.com/questions/27982577/how-to-set-a-conditional-panel-to-a-selectinput-in-shiny
library(shiny)
library(shinyalert)
library(shinydashboard)
library(DT)
library(leaflet)
library(tidyverse)
library(mapview)
library(rnaturalearth)
library(rgeos)
library(plotly)
# Data Preparation - Nettoyoge
if(!exists("foo", mode="function")) source("nettoyage.R", encoding = 'UTF-8')
# A réextraire à partir de la population entière.
Departements <- c(66,75)
Criteres <- c("age","gravite")
Criteres_visu <- c("mean_age","tauxAcc","tauxAccClasseAge", "tauxGrav","tauxGravClasseAge")
Class_Dage <- gravity %>% select(classeAge) %>% arrange(classeAge) %>% distinct
var_pdp <- names(select(prediction, -id,-pred))
mapviewOptions(
basemaps = c("Esri.WorldShadedRelief", "OpenStreetMap.DE"),
raster.palette = grey.colors,
vector.palette = colorRampPalette(c("snow", "cornflowerblue", "grey10")),
na.color = "magenta",
layers.control.pos = "topright")
# Define UI for application that draws a histogram
ui <- dashboardPage(
header = dashboardHeader(title = 'Accidents corporels 2017 - 2019'),
sidebar = dashboardSidebar(
sidebarMenu(
menuItem("Statistiques générales", tabName = "tab_general_statistics", icon = icon("car-crash")),
menuItem("Comparaison départements (PDP)", tabName = "tab_dep_comparaison", icon = icon("binoculars")),
menuItem("Carte d'indicateurs", tabName = "tab_map", icon = icon("globe-europe"))
)
),
body = dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "tab_general_statistics", class = "active",
h2("Statistiques générales"),
div("Les bases de données, extraites du fichier BAAC (Bulletin d'Analyse des Accidents de la Circulation), répertorient l'intégralité des accidents corporels de la circulation routière."),
div("Un accident corporel (mortel et non mortel) de la circulation routière relevé par les forces de l’ordre :",
tags$ul(tags$li("implique au moins une victime"),
tags$li("survient sur une voie publique ou privée, ouverte à la circulation publique"),
tags$li("implique au moins un véhicule"))),
fluidRow(
infoBox("Vision mensuelle", icon = icon("calendar-alt"), width = 6),
infoBox("Vision Horaire", icon = icon("hourglass-half"), width = 6),
),
fluidRow(
box(width = 6,
plotlyOutput("plot_stats_per_month")
),
box(width = 6,
plotlyOutput("plot_stats_per_hour")
)
),
fluidRow(
column(width = 6),
box(width = 6,
selectInput(inputId = "annee_selected", label = "Année", choices = c(2019,2018,2017,2016))
),
valueBoxOutput(outputId = "annee_selected_mini_info", width = 6)
)
),
# Second tab content
tabItem(tabName = 'tab_dep_comparaison', class = "active",
fluidRow(
infoBox("Département 62", icon = icon("mountain"), width = 6),
infoBox("Département 44", icon = icon("wind"), width = 6),
),
fluidRow(
column(width = 3),
box(width = 6,
selectInput(inputId = "var_selected", label = "Variable", choices = var_pdp)
),
column(width = 3)
),
fluidRow(
box(width = 6,
plotlyOutput("plot_pdp_box_62")
),
box(width = 6,
plotlyOutput("plot_pdp_box_44")
)
),
fluidRow(
box(width = 6,
plotlyOutput("plot_pdp_grad_62")
),
box(width = 6,
plotlyOutput("plot_pdp_grad_44")
)
)
),
# Third tab content
tabItem(tabName = "tab_map", class = "active",
fluidRow(
box(width = 2,
selectInput(inputId = "annee_visu", label = "Année", choices = c(2019,2018,2017,2016)),
selectInput(inputId = "crit_visu", label = "Critère de visualisation", choices = Criteres_visu),
conditionalPanel(
condition = "input.crit_visu === 'tauxAccClasseAge' || input.crit_visu === 'tauxGravClasseAge'",
selectInput(inputId = "class_Dage", label = "Classe d'ages ", choices = Class_Dage)),
h2("Critères"),
div("",
tags$ul(tags$li("Mean age: L'age moyen par département"),
tags$li("tauxAcc: Taux d'accident corporel par département (1/1000)"),
tags$li("tauxAccClasseAge: Taux d'accident corporel par département et par classe d'age (1/1000)"),
tags$li("tauxGrav: Taux de gravité moyen des accidents corporel par département"),
tags$li("tauxGravClasseAge: Taux de gravité moyen des accidents corporel par département et par classe d'age")
)),
),
box(width = 10,
mapviewOutput(outputId = "fr_map", width = "100%", height = 750)
)
)
)
)
)
)