├── .gitignore
├── LICENSE
├── README.md
├── elec-dashboard
├── backup.R
├── datas
│ ├── acgen.rds
│ ├── active_units.rds
│ ├── consumption.rds
│ ├── inst_cap.rds
│ └── phyflow.rds
├── funs
│ └── descriptif_application.R
├── global.R
├── server.R
├── session_info.txt
├── ui.R
└── www
│ ├── logo_dreamRs_couleur.png
│ ├── screenshot1.png
│ └── styles.css
├── gh-dashboard
├── funs
│ └── utils.R
├── global.R
├── screenshot-old.png
├── screenshot.png
├── server.R
├── ui.R
└── www
│ └── styles.css
├── olympic-medals
├── R
│ ├── data.R
│ └── visualisation.R
├── app.R
├── datas
│ └── medals_summer.rds
├── screenshot.png
└── www
│ ├── pic2.jpg
│ └── rings.jpg
├── ratp-traffic-bs4Dash
├── datas
│ ├── NVALDTOT_STAT_CATJOUR_LIGNE.rds
│ ├── info_ligne.rds
│ ├── lignes_metro.rds
│ ├── plan_metro.rds
│ ├── profil_horaire_global.rds
│ ├── profil_horaire_ligne.rds
│ └── validation_metro.rds
├── funs
│ ├── box_icon.R
│ ├── descriptif_application.R
│ ├── graph_profil_horaire.R
│ └── import_validation.R
├── global.R
├── readme.md
├── server.R
├── ui.R
└── www
│ ├── Paris_m_10_jms.svg
│ ├── Paris_m_11_jms.svg
│ ├── Paris_m_12_jms.svg
│ ├── Paris_m_13_jms.svg
│ ├── Paris_m_14_jms.svg
│ ├── Paris_m_1_jms.svg
│ ├── Paris_m_2_jms.svg
│ ├── Paris_m_3_jms.svg
│ ├── Paris_m_3bis_jms.svg
│ ├── Paris_m_4_jms.svg
│ ├── Paris_m_5_jms.svg
│ ├── Paris_m_6_jms.svg
│ ├── Paris_m_7_jms.svg
│ ├── Paris_m_7bis_jms.svg
│ ├── Paris_m_8_jms.svg
│ ├── Paris_m_9_jms.svg
│ ├── RATP.svg
│ ├── logo_blanc_ratp.png
│ ├── logo_dreamRs_couleur.png
│ ├── screenshot_app.png
│ └── styles.css
├── ratp-traffic
├── datas
│ ├── NVALDTOT_STAT_CATJOUR_LIGNE.rds
│ ├── info_ligne.rds
│ ├── lignes_metro.rds
│ ├── plan_metro.rds
│ ├── profil_horaire_global.rds
│ ├── profil_horaire_ligne.rds
│ └── validation_metro.rds
├── funs
│ ├── box_icon.R
│ ├── descriptif_application.R
│ ├── graph_profil_horaire.R
│ └── import_validation.R
├── global.R
├── server.R
├── ui.R
└── www
│ ├── Paris_m_10_jms.svg
│ ├── Paris_m_11_jms.svg
│ ├── Paris_m_12_jms.svg
│ ├── Paris_m_13_jms.svg
│ ├── Paris_m_14_jms.svg
│ ├── Paris_m_1_jms.svg
│ ├── Paris_m_2_jms.svg
│ ├── Paris_m_3_jms.svg
│ ├── Paris_m_3bis_jms.svg
│ ├── Paris_m_4_jms.svg
│ ├── Paris_m_5_jms.svg
│ ├── Paris_m_6_jms.svg
│ ├── Paris_m_7_jms.svg
│ ├── Paris_m_7bis_jms.svg
│ ├── Paris_m_8_jms.svg
│ ├── Paris_m_9_jms.svg
│ ├── logo_blanc_ratp.png
│ ├── logo_dreamRs_couleur.png
│ ├── screenshot_app.png
│ └── styles.css
├── rentree_scolaire
├── LICENSE
├── datas
│ └── rentree_etablissements.rds
├── funs
│ ├── descriptif_application.R
│ └── summarise_etablissements.R
├── global.R
├── server.R
├── session_info.txt
├── ui.R
└── www
│ ├── LICENSE
│ ├── app.js
│ ├── logo_dreamRs_couleur.png
│ ├── particles.min.js
│ ├── particlesjs-config.json
│ ├── screenshot.png
│ └── styles.css
└── tdb-naissances
├── .gitignore
├── README.md
├── datas
├── contour_departements.rds
├── contour_regions.rds
├── naissances_departement.rds
├── naissances_france.rds
└── naissances_region.rds
├── global.R
├── screenshot_app_naissances.png
├── server.R
├── ui.R
└── www
└── css_custom_styles.css
/.gitignore:
--------------------------------------------------------------------------------
1 | # History files
2 | .Rhistory
3 | .Rapp.history
4 |
5 | # Session Data files
6 | .RData
7 |
8 | # Example code in package build process
9 | *-Ex.R
10 |
11 | # Output files from R CMD build
12 | /*.tar.gz
13 |
14 | # Output files from R CMD check
15 | /*.Rcheck/
16 |
17 | # rsconnect folder
18 | */rsconnect/
19 |
20 | # RStudio files
21 | .Rproj.user/
22 | *.Rproj
23 |
24 | # produced vignettes
25 | vignettes/*.html
26 | vignettes/*.pdf
27 |
28 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
29 | .httr-oauth
30 |
31 | # knitr and R markdown default cache directories
32 | /*_cache/
33 | /cache/
34 |
35 | # Temporary files created by R markdown
36 | *.utf8.md
37 | *.knit.md
38 | .Rproj.user
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # shinyapps
2 |
3 | > Some Shiny applications
4 |
5 | All these applications are available on our Shiny server : http://shinyapps.dreamrs.fr/
6 |
7 |
8 |
9 | ## C'est la rentrée !
10 |
11 | An application to explore the name of public schools in France. The names are represented by the gender, activity, and century of the personality by which establishments were named. More frequent names can be visualized, and you can access to the biography of a personality. All application is in French.
12 |
13 | **Packages** : The application use the following packages : [`shiny`](https://shiny.rstudio.com/), [`shinyWidgets`](https://github.com/dreamRs/shinyWidgets), [`billboarder`](https://github.com/dreamRs/billboarder). To see which versions of these packages are used (and dependancies), look at the file `session_info.txt` in app directory. If packages are not installed, they will be on application launch.
14 |
15 | **Data sources** : Names of shcools are from [data.gouv](https://www.data.gouv.fr/fr/datasets/etablissements-scolaires/), data about personality are from Wikipedia and DBpedia.
16 |
17 | Launch application :
18 |
19 | ```r
20 | shiny::runGitHub(repo = "dreamRs/shinyapps", subdir = "rentree_scolaire")
21 | ```
22 |
23 | 
24 |
25 |
26 |
27 |
28 | ## Electricity dashboard
29 |
30 | Explore power consumption, production and exchanges in France via RTE's API.
31 |
32 | **Packages** : The application use the following packages : [`shiny`](https://shiny.rstudio.com/), [`shinyWidgets`](https://github.com/dreamRs/shinyWidgets), [`billboarder`](https://github.com/dreamRs/billboarder), [`leaflet`](https://rstudio.github.io/leaflet/), [`rte.data`](https://github.com/dreamRs/rte.data). To see which versions of these packages are used (and dependancies), look at the file `session_info.txt` in app directory.
33 |
34 | **Data sources** : The data is recovered via the RTE API, a key is required to recover the data but backup data is included in the application to be able to launch it without having access to the API.
35 |
36 | Launch application :
37 |
38 | ```r
39 | shiny::runGitHub(repo = "dreamRs/shinyapps", subdir = "elec-dashboard")
40 | ```
41 | 
42 |
43 |
44 |
45 |
46 | ## RATP Traffic
47 |
48 | Explore Paris metro traffic ; how it can vary according to the type of day or according to the line or the station.
49 | Also, discover the different characteristics of each line.
50 |
51 | **Packages** : The application use the following packages :
52 | [`shiny`](https://shiny.rstudio.com/), [`shinyWidgets`](https://github.com/dreamRs/shinyWidgets),
53 | [`shinythemes`]("https://rstudio.github.io/shinythemes/"), [`shinydashboard`]("https://rstudio.github.io/shinydashboard/"),
54 | [`dplyr`]("https://github.com/tidyverse/dplyr"),
55 | [`leaflet`](https://rstudio.github.io/leaflet/), [`leaflet.extras`]("https://github.com/bhaskarvk/leaflet.extras"),
56 | [`scales`]("https://github.com/r-lib/scales"),
57 | [`billboarder`](https://github.com/dreamRs/billboarder),
58 | [`stringr`]("https://github.com/tidyverse/stringr")
59 |
60 |
61 |
62 | **Data sources** : The data is recovered via the STIF Open data website : https://opendata.stif.info/
63 |
64 |
65 |
66 | Launch application :
67 |
68 | ```r
69 | shiny::runGitHub(repo = "dreamRs/shinyapps", subdir = "ratp-traffic")
70 | ```
71 |
72 | 
73 |
74 |
75 |
76 |
77 | ## RATP Traffic (bs4Dash)
78 |
79 | The same application as above but using [{bs4Dash}](https://github.com/RinteRface/bs4Dash) framework by @DivadNojnarg, to give it a modern look!
80 |
81 | Launch application :
82 |
83 | ```r
84 | shiny::runGitHub(repo = "dreamRs/shinyapps", subdir = "ratp-traffic-bs4Dash")
85 | ```
86 |
87 | 
88 |
89 |
90 |
91 |
92 | ## GitHub dashboard
93 |
94 | Quick dashboard of a GitHub user/organization.
95 |
96 | :warning: It is recommended to have a registered GitHub token / PAT (see `?gh::gh_whoami`)
97 |
98 | **Packages** : The application use the following packages :
99 | [`shiny`](https://shiny.rstudio.com/), [`shinyWidgets`](https://github.com/dreamRs/shinyWidgets), [`ggplot2`](https://github.com/tidyverse/ggplot2),
100 | [`gh`](https://github.com/r-lib/gh).
101 |
102 |
103 | Launch application :
104 |
105 | ```r
106 | shiny::runGitHub(repo = "dreamRs/shinyapps", subdir = "gh-dashboard")
107 | ```
108 | 
109 |
110 |
111 | ## Les naissances en France
112 |
113 | Explore births in France ; how it can vary according to each region or according to each department.
114 | Also, discover the number of births and the birth rate between 1975 and 2020.
115 |
116 | **Packages** : The application use the following packages :
117 | [`shiny`](https://shiny.rstudio.com/), [`shinyWidgets`](https://github.com/dreamRs/shinyWidgets),
118 | [`dplyr`]("https://github.com/tidyverse/dplyr"),
119 | [`leaflet`](https://rstudio.github.io/leaflet/),
120 | [`apexcharter`](https://dreamrs.github.io/apexcharter/),
121 | [`toastui`](https://github.com/dreamRs/toastui),
122 | [`bslib`](https://rstudio.github.io/bslib/)
123 |
124 |
125 | **Data sources** : The data is recovered via the French government Open data website : https://www.data.gouv.fr/fr/
126 |
127 |
128 |
129 | Launch application :
130 |
131 | ```r
132 | shiny::runGitHub(repo = "dreamRs/shinyapps", subdir = "tdb-naissances")
133 | ```
134 | 
135 | ## Summer Olympic Games medals
136 |
137 | Explore the countries that have won the most medals for all the modern summer olympic games, between 1896 and 2020. The medal type (gold, silver, bronze) distribution for each **country**, **slug game edition** and **discipline**.
138 |
139 | **Packages** : The application uses the following packages :
140 | [`shiny`](https://shiny.rstudio.com/),
141 | [`shinyWidgets`](https://github.com/dreamRs/shinyWidgets),
142 | [`shinydashboard`](https://github.com/dreamRs/shinydashboard),
143 | [`dplyr`]("https://github.com/tidyverse/dplyr"),
144 | [`ggplot2`]("https://github.com/tidyverse/ggplot2"),
145 | [`ggthemes`]("https://cran.r-project.org/package=ggthemes"),
146 | [`bslib`](https://rstudio.github.io/bslib/)
147 | [`data.table`](https://github.com/Rdatatable/data.table)
148 | [`reactable`](https://cran.r-project.org/package=reactable)
149 | [`tidyr`](https://rstudio.github.io/tidyr/)
150 | [`ggtext`](https://cran.r-project.org/package=ggtext)
151 |
152 |
153 | **Data sources** : The data is recovered via Kaggle at:
154 | [](https://www.kaggle.com/datasets/piterfm/olympic-games-medals-19862018)
155 |
156 |
157 | Launch application :
158 |
159 | ```r
160 | shiny::runGitHub(repo = "dreamRs/shinyapps", subdir = "olympic-medals")
161 | ```
162 |
163 | 
164 |
165 |
166 |
--------------------------------------------------------------------------------
/elec-dashboard/backup.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | # ------------------------------------------------------------------------
4 | #
5 | # Title : Backup data
6 | # By : Victor
7 | # Date : 2018-04-14
8 | #
9 | # ------------------------------------------------------------------------
10 |
11 |
12 |
13 | # Packages ----------------------------------------------------------------
14 |
15 | library( rte.data )
16 |
17 |
18 |
19 |
20 | # Dates -------------------------------------------------------------------
21 |
22 | start <- Sys.Date() - 7
23 | end<- Sys.Date()
24 |
25 |
26 |
27 | # Consumption -------------------------------------------------------------
28 |
29 | consumption <- get_consumption(
30 | resource = "short_term",
31 | type = c("REALISED", "D-1"),
32 | start_date = start,
33 | end_date = end + 1
34 | )
35 | saveRDS(consumption, file = "dashboard_elec/datas/consumption.rds")
36 |
37 |
38 |
39 |
40 | # Actual generation -------------------------------------------------------
41 |
42 | acgen <- get_actual_generation(
43 | resource = "actual_generations_per_production_type",
44 | start_date = start,
45 | end_date = end
46 | )
47 | saveRDS(acgen, file = "dashboard_elec/datas/acgen.rds")
48 |
49 |
50 |
51 |
52 | # Physical flows ----------------------------------------------------------
53 |
54 | phyflow <- get_physical_flows(
55 | start_date = start,
56 | end_date = end
57 | )
58 | saveRDS(phyflow, file = "dashboard_elec/datas/phyflow.rds")
59 |
60 |
61 |
62 | # Active units ------------------------------------------------------------
63 |
64 | active_units <- retrieve_active_units(
65 | start_date = start,
66 | end_date = end
67 | )
68 | saveRDS(active_units, file = "dashboard_elec/datas/active_units.rds")
69 |
70 |
71 |
72 | # Installed capacities ----------------------------------------------------
73 |
74 | inst_cap <- get_open_api(
75 | api = "generation_installed_capacities",
76 | resource = "capacities_per_production_unit"
77 | )
78 | saveRDS(inst_cap, file = "dashboard_elec/datas/inst_cap.rds")
79 |
80 |
--------------------------------------------------------------------------------
/elec-dashboard/datas/acgen.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/elec-dashboard/datas/acgen.rds
--------------------------------------------------------------------------------
/elec-dashboard/datas/active_units.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/elec-dashboard/datas/active_units.rds
--------------------------------------------------------------------------------
/elec-dashboard/datas/consumption.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/elec-dashboard/datas/consumption.rds
--------------------------------------------------------------------------------
/elec-dashboard/datas/inst_cap.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/elec-dashboard/datas/inst_cap.rds
--------------------------------------------------------------------------------
/elec-dashboard/datas/phyflow.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/elec-dashboard/datas/phyflow.rds
--------------------------------------------------------------------------------
/elec-dashboard/funs/descriptif_application.R:
--------------------------------------------------------------------------------
1 |
2 | #' Modal containing informations about the application
3 | #'
4 | #' @return a modal ui to use in \code{\link[shiny]{showModal}}
5 | # @export
6 | #'
7 | # @examples
8 | descriptif_application <- function() {
9 | modalDialog(
10 | title = "About this application",
11 | tags$div(
12 | class = "dreamrs",
13 | tags$b("Data :"),
14 | tags$ul(
15 | tags$li(
16 | "The data comes from RTE's data portal and is retrieved via their API :",
17 | tags$a("data.rte-france.com",
18 | href = "https://data.rte-france.com/")
19 | ),
20 | tags$li(
21 | "The geolocation of the production units comes from",
22 | tags$a("Open Power System Data", href = "https://github.com/Open-Power-System-Data/conventional_power_plants")
23 | )
24 | ),
25 | tags$b("Packages :"),
26 | tags$ul(
27 | tags$li(tags$a("shiny", href = "https://shiny.rstudio.com/"), "fo the application."),
28 | tags$li(tags$a("shinyWidgets", href = "https://github.com/dreamRs/shinyWidgets"), "to customize appearance."),
29 | tags$li(tags$a("billboarder", href = "https://github.com/dreamRs/billboarder"), "for visualisation in D3js."),
30 | tags$li(tags$a("leaflet", href = "https://rstudio.github.io/leaflet/"), "for maps."),
31 | tags$li(tags$a("rte.data", href = "https://github.com/dreamRs/rte.data"), "to access RTE API.")
32 | ),
33 | tags$b("Authors :"),
34 | tags$p("This application was developed by Fanny Meyer and Victor Perrier, you can follow us on Twitter here :"),
35 | tags$a(
36 | class = "btn btn-default", icon("twitter"), "@dreamRs",
37 | href = "https://twitter.com/dreamRs_fr", style = "background-color: #1DA1F2; color: #FFF;"
38 | ),
39 | tags$a(
40 | class = "btn btn-default", icon("twitter"), "@Fanny",
41 | href = "https://twitter.com/_mfaan", style = "background-color: #1DA1F2; color: #FFF;"
42 | ),
43 | tags$a(
44 | class = "btn btn-default", icon("twitter"), "@Victor",
45 | href = "https://twitter.com/_pvictorr", style = "background-color: #1DA1F2; color: #FFF;"
46 | ),
47 | tags$span("or you can visit our website :", tags$a("dreamrs.fr", href = "https://www.dreamrs.fr/"))
48 | ),
49 | easyClose = TRUE, size = "l",
50 | footer = modalButton("Close")
51 | )
52 | }
53 |
54 |
55 |
--------------------------------------------------------------------------------
/elec-dashboard/global.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | # ------------------------------------------------------------------------
4 | #
5 | # Title : Dashboard Elec - Global
6 | # By : Victor
7 | # Date : 2018-03-28
8 | #
9 | # ------------------------------------------------------------------------
10 |
11 |
12 |
13 | # Packages ----------------------------------------------------------------
14 |
15 | library( data.table )
16 | library( ggplot2 )
17 | library( rte.data )
18 | library( shiny )
19 | library( shinyWidgets )
20 | library( billboarder )
21 | library( leaflet )
22 |
23 |
24 |
25 | # API keys ----------------------------------------------------------------
26 |
27 | # for this application to work, you will need the following keys for RTE-data API
28 |
29 | # https://bit.ly/2HpTbTB
30 | # set_key(api = "consumption", key = "BASE64_KEY==")
31 |
32 | # https://bit.ly/2GOt9MM
33 | # set_key(api = "physical_flow", key = "BASE64_KEY==")
34 |
35 | # https://bit.ly/2JDSYNp
36 | # set_key(api = "actual_generation", key = "BASE64_KEY==")
37 |
38 | # https://bit.ly/2qOgCiG
39 | # set_key(api = "generation_installed_capacities", key = "BASE64_KEY==")
40 |
41 |
42 |
43 | # Funs --------------------------------------------------------------------
44 |
45 | source("funs/descriptif_application.R")
46 |
47 |
48 | # Misc --------------------------------------------------------------------
49 |
50 | sector_list <- list(
51 | renewable = c("SOLAR", "HYDRO_RUN_OF_RIVER_AND_POUNDAGE",
52 | "HYDRO_PUMPED_STORAGE", "BIOMASS", "WIND_ONSHORE"),
53 | fossil = c("FOSSIL_OIL", "FOSSIL_GAS", "FOSSIL_HARD_COAL"),
54 | nuclear = c("NUCLEAR")
55 | )
56 |
57 |
58 | # session_info ------------------------------------------------------------
59 |
60 | # sink("dashboard_elec/session_info.txt")
61 | # devtools::session_info()
62 | # sink()
63 |
64 |
65 |
--------------------------------------------------------------------------------
/elec-dashboard/server.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : Dashboard Elec - Server
5 | # By : Victor
6 | # Date : 2018-03-28
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 |
12 | # Server ------------------------------------------------------------------
13 |
14 | function(input, output, session) {
15 |
16 | # Tokens list
17 | tokens <- list(
18 |
19 | )
20 |
21 |
22 | # Consumption Forecast ----
23 |
24 | confirm_consumption <- reactiveValues(x = TRUE, time = Sys.time())
25 | observeEvent(input$confirm_consumption, {
26 | confirm_consumption$x <- (is.null(input$confirm_consumption) || !input$confirm_consumption)
27 | confirm_consumption$time <- Sys.time()
28 | }, ignoreNULL = TRUE)
29 | observeEvent(input$refresh, {
30 | confirm_consumption$x <- TRUE
31 | confirm_consumption$time <- Sys.time()
32 | })
33 |
34 | consumption_r <- reactive({
35 | confirm_consumption$time
36 | if (confirm_consumption$x) {
37 | res_api <- try(get_consumption(
38 | resource = "short_term",
39 | type = c("REALISED", "D-1"),
40 | start_date = input$dates[1],
41 | end_date = input$dates[2] + 1,
42 | token = tokens$consumption
43 | ), silent = TRUE)
44 | } else {
45 | res_api <- readRDS(file = "datas/consumption.rds")
46 | }
47 | if ("try-error" %in% class(res_api)) {
48 | confirmSweetAlert(
49 | session = session,
50 | inputId = "confirm_consumption",
51 | type = "error",
52 | title = "API request failed",
53 | text = attr(res_api, "condition")$message,
54 | btn_labels = c("Retry", "Use backup data"),
55 | danger_mode = FALSE
56 | )
57 | return(NULL)
58 | } else {
59 | return(res_api)
60 | }
61 | })
62 |
63 | output$plot_consumption <- renderBillboarder({
64 | req(consumption_r())
65 | autoplot(consumption_r(), interactive = TRUE) %>%
66 | bb_svg(classname = "plot-spin") %>%
67 | bb_line(classes = list("bb-line-forecast", "bb-line-observed"))
68 | })
69 |
70 |
71 | output$gap_consumption <- renderUI({
72 | req(consumption_r())
73 | dat <- consumption_r()
74 | dat <- unique(dat, by = c("type", "start_date"))
75 | dat2 <- dcast(data = dat, formula = start_date ~ type, value.var = "value")
76 | dat2 <- dat2[!is.na(REALISED), list(
77 | pred = sum(`D-1`) / 4000,
78 | obs = sum(REALISED) / 4000,
79 | ecart = (sum(`D-1`) - sum(REALISED)) / sum(REALISED) * 100
80 | )]
81 | tags$span(
82 | "Overall forecast:",
83 | tags$b(formatC(dat2$pred, big.mark = ", ", digits = 1, format = "f")),
84 | "GWh",
85 | "(", HTML(paste0(
86 | ifelse(dat2$ecart > 0, "+", ""),
87 | tags$b(formatC(dat2$ecart, digits = 2, format = "f")),
88 | "%"
89 | )), " versus real consumption)"
90 | )
91 | })
92 |
93 |
94 |
95 | # Generation by sector ----
96 |
97 | confirm_acgen <- reactiveValues(x = TRUE, time = Sys.time())
98 | observeEvent(input$confirm_acgen, {
99 | confirm_acgen$x <- (is.null(input$confirm_acgen) || !input$confirm_acgen)
100 | confirm_acgen$time <- Sys.time()
101 | }, ignoreNULL = TRUE)
102 | observeEvent(input$refresh, {
103 | confirm_acgen$x <- TRUE
104 | confirm_acgen$time <- Sys.time()
105 | })
106 |
107 | generation_sector_r <- reactive({
108 | confirm_acgen$time
109 | if (confirm_acgen$x) {
110 | res_api <- try(get_actual_generation(
111 | resource = "actual_generations_per_production_type",
112 | start_date = input$dates[1],
113 | end_date = input$dates[2],
114 | token = tokens$actual_generation
115 | ), silent = TRUE)
116 | } else {
117 | res_api <- readRDS(file = "datas/acgen.rds")
118 | }
119 | if ("try-error" %in% class(res_api)) {
120 | confirmSweetAlert(
121 | session = session,
122 | inputId = "confirm_acgen",
123 | type = "error",
124 | title = "API request failed",
125 | text = attr(res_api, "condition")$message,
126 | btn_labels = c("Retry", "Use backup data"),
127 | danger_mode = FALSE
128 | )
129 | return(NULL)
130 | } else {
131 | return(res_api)
132 | }
133 | })
134 |
135 | output$plot_generation_sector <- renderBillboarder({
136 | req(generation_sector_r())
137 | dat <- generation_sector_r()
138 |
139 | dat[, sector := NA_character_]
140 | dat[production_type %chin% sector_list$renewable, sector := "renewable"]
141 | dat[production_type %chin% sector_list$fossil, sector := "fossil"]
142 | dat[production_type %chin% sector_list$nuclear, sector := "nuclear"]
143 | dat <- dat[!is.na(sector)]
144 | sector_prod <- dat[, list(value = sum(value, na.rm = TRUE)), by = sector]
145 | sector_prod[, p := value / sum(value) * 100]
146 |
147 | updateProgressBar(session = session, id = "pb_nuclear", value = sector_prod[sector == "nuclear", c(p)])
148 | updateProgressBar(session = session, id = "pb_fossil", value = sector_prod[sector == "fossil", c(p)])
149 | updateProgressBar(session = session, id = "pb_renewable", value = sector_prod[sector == "renewable", c(p)])
150 |
151 | autoplot(generation_sector_r(), interactive = TRUE) %>%
152 | bb_svg(classname = "plot-spin") %>%
153 | bb_labs(title = "")
154 | })
155 |
156 |
157 |
158 | # Exchange ----
159 |
160 | confirm_phyflow <- reactiveValues(x = TRUE, time = Sys.time())
161 | observeEvent(input$confirm_phyflow, {
162 | confirm_phyflow$x <- (is.null(input$confirm_phyflow) || !input$confirm_phyflow)
163 | confirm_phyflow$time <- Sys.time()
164 | }, ignoreNULL = TRUE)
165 | observeEvent(input$refresh, {
166 | confirm_phyflow$x <- TRUE
167 | confirm_phyflow$time <- Sys.time()
168 | })
169 |
170 | exchange_r <- reactive({
171 | confirm_phyflow$time
172 | if (confirm_phyflow$x) {
173 | res_api <- try(get_physical_flows(
174 | start_date = input$dates[1],
175 | end_date = input$dates[2],
176 | token = tokens$physical_flow
177 | ), silent = TRUE)
178 | } else {
179 | res_api <- readRDS(file = "datas/phyflow.rds")
180 | }
181 | if ("try-error" %in% class(res_api)) {
182 | confirmSweetAlert(
183 | session = session,
184 | inputId = "confirm_phyflow",
185 | type = "error",
186 | title = "API request failed",
187 | text = attr(res_api, "condition")$message,
188 | btn_labels = c("Retry", "Use backup data"),
189 | danger_mode = FALSE
190 | )
191 | return(NULL)
192 | } else {
193 | return(res_api)
194 | }
195 | })
196 |
197 |
198 | output$plot_exchange <- renderBillboarder({
199 | req(exchange_r())
200 | autoplot(exchange_r(), by_country = input$by_country, interactive = TRUE) %>%
201 | bb_svg(classname = "plot-spin")
202 | })
203 |
204 |
205 | # Active units ----
206 |
207 | confirm_active <- reactiveValues(x = TRUE, time = Sys.time())
208 | observeEvent(input$confirm_active, {
209 | confirm_active$x <- (is.null(input$confirm_active) || !input$confirm_active)
210 | confirm_active$time <- Sys.time()
211 | }, ignoreNULL = TRUE)
212 | observeEvent(input$refresh, {
213 | confirm_active$x <- TRUE
214 | confirm_active$time <- Sys.time()
215 | })
216 |
217 | active_units_r <- reactive({
218 | confirm_active$time
219 | if (confirm_active$x) {
220 | res_api <- try(retrieve_active_units(
221 | start_date = input$dates[1],
222 | end_date = input$dates[2],
223 | tokens = tokens
224 | ), silent = TRUE)
225 | } else {
226 | res_api <- readRDS(file = "datas/active_units.rds")
227 | }
228 | if ("try-error" %in% class(res_api)) {
229 | confirmSweetAlert(
230 | session = session,
231 | inputId = "confirm_active",
232 | type = "error",
233 | title = "API request failed",
234 | text = attr(res_api, "condition")$message,
235 | btn_labels = c("Retry", "Use backup data"),
236 | danger_mode = FALSE
237 | )
238 | return(NULL)
239 | } else {
240 | return(res_api)
241 | }
242 | })
243 |
244 |
245 | confirm_installed <- reactiveValues(x = TRUE, time = Sys.time())
246 | observeEvent(input$confirm_installed, {
247 | confirm_installed$x <- (is.null(input$confirm_installed) || !input$confirm_installed)
248 | confirm_installed$time <- Sys.time()
249 | }, ignoreNULL = TRUE)
250 | observeEvent(input$refresh, {
251 | confirm_installed$x <- TRUE
252 | confirm_installed$time <- Sys.time()
253 | })
254 |
255 | installed_capacities_r <- reactive({
256 | confirm_installed$time
257 | if (confirm_installed$x) {
258 | res_api <- try(get_open_api(
259 | api = "generation_installed_capacities",
260 | resource = "capacities_per_production_unit",
261 | token = tokens$generation_installed_capacities
262 | ), silent = TRUE)
263 | } else {
264 | res_api <- readRDS(file = "datas/inst_cap.rds")
265 | }
266 | if ("try-error" %in% class(res_api)) {
267 | confirmSweetAlert(
268 | session = session,
269 | inputId = "confirm_installed",
270 | type = "error",
271 | title = "API request failed",
272 | text = attr(res_api, "condition")$message,
273 | btn_labels = c("Retry", "Use backup data"),
274 | danger_mode = FALSE
275 | )
276 | return(NULL)
277 | } else {
278 | return(res_api)
279 | }
280 | })
281 |
282 | output$plot_active_units_p <- renderBillboarder({
283 | req(active_units_r())
284 | autoplot(active_units_r(), interactive = TRUE) %>%
285 | bb_svg(classname = "plot-spin")
286 | })
287 |
288 | output$map_capacities <- renderLeaflet({
289 | if (input$capacities_plot == 'map') {
290 | req(active_units_r())
291 | autoplot(active_units_r(), interactive = TRUE, map = TRUE)
292 | } else if (input$capacities_plot == 'global') {
293 | req(installed_capacities_r())
294 | autoplot(installed_capacities_r(), interactive = TRUE)
295 | }
296 | })
297 |
298 |
299 | # About the app ----
300 | observeEvent(input$about, {
301 | showModal(descriptif_application())
302 | })
303 |
304 | }
305 |
--------------------------------------------------------------------------------
/elec-dashboard/session_info.txt:
--------------------------------------------------------------------------------
1 | setting value
2 | version R version 3.4.4 (2018-03-15)
3 | system x86_64, mingw32
4 | ui RStudio (1.1.447)
5 | language (EN)
6 | collate French_France.1252
7 | tz Europe/Berlin
8 | date 2018-04-27
9 |
10 | package * version date source
11 | base * 3.4.4 2018-03-15 local
12 | billboarder * 0.2.1.920 2018-04-27 local
13 | colorspace 1.3-2 2016-12-14 CRAN (R 3.4.4)
14 | compiler 3.4.4 2018-03-15 local
15 | crosstalk 1.0.0 2016-12-21 CRAN (R 3.4.4)
16 | crul 0.5.2 2018-02-24 CRAN (R 3.4.4)
17 | curl 3.2 2018-03-28 CRAN (R 3.4.4)
18 | data.table * 1.10.4-3 2017-10-27 CRAN (R 3.4.4)
19 | datasets * 3.4.4 2018-03-15 local
20 | devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
21 | digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
22 | ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.4.4)
23 | glue 1.2.0 2017-10-29 CRAN (R 3.4.4)
24 | graphics * 3.4.4 2018-03-15 local
25 | grDevices * 3.4.4 2018-03-15 local
26 | grid 3.4.4 2018-03-15 local
27 | gtable 0.2.0 2016-02-26 CRAN (R 3.4.4)
28 | htmltools 0.3.6 2017-04-28 CRAN (R 3.4.4)
29 | htmlwidgets 1.2 2018-04-19 CRAN (R 3.4.4)
30 | httpuv 1.4.1 2018-04-21 CRAN (R 3.4.4)
31 | jsonlite 1.5 2017-06-01 CRAN (R 3.4.4)
32 | later 0.7.1 2018-03-07 CRAN (R 3.4.4)
33 | lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.4)
34 | leaflet * 2.0.0 2018-04-20 CRAN (R 3.4.4)
35 | magrittr 1.5 2014-11-22 CRAN (R 3.4.4)
36 | memoise 1.1.0 2017-04-21 CRAN (R 3.4.4)
37 | methods * 3.4.4 2018-03-15 local
38 | mime 0.5 2016-07-07 CRAN (R 3.4.1)
39 | munsell 0.4.3 2016-02-13 CRAN (R 3.4.4)
40 | pillar 1.2.1 2018-02-27 CRAN (R 3.4.4)
41 | plyr 1.8.4 2016-06-08 CRAN (R 3.4.4)
42 | promises 1.0.1 2018-04-13 CRAN (R 3.4.4)
43 | R6 2.2.2 2017-06-17 CRAN (R 3.4.4)
44 | Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4)
45 | rlang 0.2.0.9001 2018-04-17 Github (r-lib/rlang@82b2727)
46 | rstudioapi 0.7 2017-09-07 CRAN (R 3.4.4)
47 | rte.data * 0.0.0.9200 2018-04-27 local
48 | scales 0.5.0.9000 2018-04-17 Github (hadley/scales@d767915)
49 | shiny * 1.0.5 2017-08-23 CRAN (R 3.4.4)
50 | shinyWidgets * 0.4.2.910 2018-04-22 local
51 | stats * 3.4.4 2018-03-15 local
52 | tibble 1.4.2 2018-01-22 CRAN (R 3.4.4)
53 | tools 3.4.4 2018-03-15 local
54 | triebeard 0.3.0 2016-08-04 CRAN (R 3.4.4)
55 | urltools 1.7.0 2018-01-20 CRAN (R 3.4.4)
56 | utils * 3.4.4 2018-03-15 local
57 | withr 2.1.2 2018-04-17 Github (jimhester/withr@79d7b0d)
58 | xtable 1.8-2 2016-02-05 CRAN (R 3.4.4)
59 | yaml 2.1.18 2018-03-08 CRAN (R 3.4.4)
60 |
--------------------------------------------------------------------------------
/elec-dashboard/ui.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : Dashboard Elec - UI
5 | # By : Victor
6 | # Date : 2018-03-28
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 |
12 | # UI ----------------------------------------------------------------------
13 |
14 | fluidPage(
15 |
16 | tags$head(
17 | tags$link(href="styles.css", rel="stylesheet", type="text/css")
18 | ),
19 |
20 | fluidRow(
21 |
22 | column(
23 | width = 10, offset = 1,
24 |
25 | tags$div(
26 | class = "title",
27 | tags$br(),
28 | tags$h1("Electricity dashboard", class = "titre"),
29 | tags$h2("French electricity production and consumption (via RTE)", class = "soustitre"),
30 | tags$br(),
31 |
32 | tags$span(icon("bolt"), class = "main-icon")
33 | ),
34 |
35 | tags$div(
36 | style = "width: 100%; overflow: hidden;",
37 | tags$div(
38 | style = "width: 300px; float: left;",
39 | dateRangeInput(
40 | inputId = "dates", label = NULL,
41 | start = Sys.Date() - 7, end = Sys.Date(),
42 | min = Sys.Date() - 45, max = Sys.Date(), width = "300px"
43 | )
44 | ),
45 | tags$div(
46 | style = "margin-left: 320px;",
47 | actionButton(
48 | inputId = "refresh", label = NULL, icon = icon("refresh"),
49 | style = "height: 30px; padding: 0px 12px;"
50 | )
51 | )
52 | ),
53 |
54 | verticalTabsetPanel(
55 |
56 | verticalTabPanel(
57 | title = "Forecast", icon = icon("line-chart", class = "fa-2x"),
58 | addSpinner(
59 | billboarderOutput(outputId = "plot_consumption", height = "520px"),
60 | spin = "folding-cube"
61 | ),
62 | uiOutput(outputId = "gap_consumption")
63 | ),
64 |
65 | verticalTabPanel(
66 | title = "Generation by sector", icon = icon("gears", class = "fa-2x"),
67 | tags$b("% of main sectors:"),
68 | progressBar(id = "pb_nuclear", value = 0, display_pct = TRUE, title = "Nuclear", status = "nuclear"),
69 | progressBar(id = "pb_fossil", value = 0, display_pct = TRUE, title = "Fossil", status = "fossil"),
70 | progressBar(id = "pb_renewable", value = 0, display_pct = TRUE, title = "Renewable", status = "renewable"),
71 | tags$br(),
72 | tags$b("Details by sectors:"),
73 | addSpinner(
74 | billboarderOutput(outputId = "plot_generation_sector", height = "430px"),
75 | spin = "folding-cube"
76 | )
77 | ),
78 |
79 | verticalTabPanel(
80 | title = "Exchange", icon = icon("exchange", class = "fa-2x"),
81 | addSpinner(
82 | billboarderOutput(outputId = "plot_exchange", height = "450px"),
83 | spin = "folding-cube"
84 | ),
85 | materialSwitch(
86 | inputId = "by_country",
87 | label = "See details by country",
88 | value = FALSE, right = TRUE
89 | )
90 | ),
91 |
92 | verticalTabPanel(
93 | title = "Generation capacities", icon = icon("industry", class = "fa-2x"),
94 | radioGroupButtons(
95 | inputId = "capacities_plot",
96 | label = "Active production units",
97 | choiceNames = list(
98 | tags$span(icon("percent"), "Summary"),
99 | tags$span(icon("map"), "Map"),
100 | tags$span(icon("industry"), "Global")
101 | ),
102 | choiceValues = c("summary", "map", "global"),
103 | status = "dreamrs", justified = TRUE, selected = "summary"
104 | ),
105 | conditionalPanel(
106 | condition = "input.capacities_plot == 'summary'",
107 | addSpinner(
108 | billboarderOutput(outputId = "plot_active_units_p", height = "520px"),
109 | spin = "folding-cube"
110 | )
111 | ),
112 | conditionalPanel(
113 | condition = "input.capacities_plot != 'summary'",
114 | addSpinner(
115 | leafletOutput(outputId = "map_capacities", height = "520px"),
116 | spin = "folding-cube"
117 | )
118 | )
119 | )
120 |
121 | ),
122 | br(),
123 | actionLink(
124 | inputId = "about", label = "about the application", icon = NULL,
125 | tags$img(src = "logo_dreamRs_couleur.png", style = "width: 50px; float:left; margin-right: 10px;"),
126 | style = "color: #112446; padding: 5px; line-height:25px;", class = "pull-right"
127 | )
128 |
129 | )
130 |
131 | )
132 |
133 | )
134 |
--------------------------------------------------------------------------------
/elec-dashboard/www/logo_dreamRs_couleur.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/elec-dashboard/www/logo_dreamRs_couleur.png
--------------------------------------------------------------------------------
/elec-dashboard/www/screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/elec-dashboard/www/screenshot1.png
--------------------------------------------------------------------------------
/elec-dashboard/www/styles.css:
--------------------------------------------------------------------------------
1 |
2 | .titre {
3 | font-family: Georgia, "Times New Roman", Times, serif;
4 | font-size:28px;
5 | margin-top: 5px; margin-bottom: 0px;
6 | text-align: left;
7 | font-weight: normal;
8 | color: #222;
9 | }
10 |
11 | .soustitre {
12 | font-family: "Lucida Grande", Tahoma;
13 | font-size: 14px;
14 | font-weight: lighter;
15 | font-variant: normal;
16 | text-transform: uppercase;
17 | color: #666666;
18 | margin-top: 10px;
19 | text-align: left;
20 | letter-spacing: 0.3em;
21 | }
22 |
23 |
24 | body {
25 | font-family: Georgia, "Times New Roman", Times, serif;
26 | }
27 |
28 |
29 |
30 | #magnifying-glass
31 | {
32 | font-size: 30em; /* This controls the size. */
33 | display: inline-block;
34 | width: 0.4em;
35 | height: 0.4em;
36 | border: 0.1em solid red;
37 | position: fixed;
38 | top: 10px;
39 | left: 10px;
40 | border-radius: 0.35em;
41 | }
42 | #magnifying-glass::before
43 | {
44 | content: "";
45 | display: inline-block;
46 | position: absolute;
47 | right: -0.25em;
48 | bottom: -0.1em;
49 | border-width: 0;
50 | background: red;
51 | width: 0.35em;
52 | height: 0.08em;
53 | -webkit-transform: rotate(45deg);
54 | -moz-transform: rotate(45deg);
55 | -ms-transform: rotate(45deg);
56 | -o-transform: rotate(45deg);
57 | }
58 |
59 |
60 |
61 | .main-icon {
62 | position: absolute;
63 | top: -35px;
64 | right: 15px;
65 | color: #F2F2F2;
66 | font-size: 1100%;
67 | z-index: -1;
68 | }
69 |
70 | .dreamrs {
71 | background-image:url(logo_dreamRs_couleur.png);
72 | background-repeat:no-repeat;
73 | background-position:right bottom;
74 | background-size: 156px 100px;
75 | }
76 |
77 |
78 | .progress {
79 | margin-bottom: 3px !important;
80 | }
81 | .progress-bar-nuclear {
82 | background-color: #f8ca4c;
83 | }
84 | .progress-bar-fossil {
85 | background-color: #848484;
86 | }
87 | .progress-bar-renewable {
88 | background-color: #088A08;
89 | }
90 |
91 |
92 | .material-switch > input[type="checkbox"]:checked + label::after {
93 | background: #112446;
94 | }
95 |
96 |
97 | .btn-dreamrs {
98 | background-color: #112446;
99 | color: #fff;
100 | border-color: #112446;
101 | }
102 |
103 | .btn-dreamrs:hover {
104 | color: #fff;
105 | }
106 |
107 | .btn-dreamrs.active {
108 | color: #112446;
109 | background-color: #fff;
110 | border-color: #112446;
111 | }
112 |
113 |
114 | /* Charts */
115 |
116 | .plot-spin {
117 | background: #FFFFFF;
118 | }
119 |
120 | .bb-line-forecast {
121 | stroke-width: 2px;
122 | }
123 |
124 | .bb-line-observed {
125 | stroke-dasharray: 12 4; stroke-width: 2px;
126 | }
127 |
--------------------------------------------------------------------------------
/gh-dashboard/funs/utils.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | #' Retrieve infos for a GitHub account
4 | #'
5 | #' @param user GitHub username
6 | #'
7 | #' @examples
8 | #' gh_infos("dreamRs")
9 | gh_infos <- function(user) {
10 |
11 | # repo infos
12 | user_repo <- gh("/users/:user/repos", user = user, .limit = Inf)
13 | if (length(user_repo) < 1)
14 | return(NULL)
15 | if (length(user_repo) == 1 && user_repo == "")
16 | return(NULL)
17 | user_repo <- lapply(user_repo, `[`, c("name", "stargazers_count", "forks", "open_issues", "watchers"))
18 | user_repo <- rbindlist(user_repo)
19 | user_repo <- user_repo[order(stargazers_count, decreasing = FALSE)]
20 | user_repo[, name := factor(name, levels = name)]
21 | # user_repo <- tail(user_repo, 20)
22 |
23 | # repos visitors
24 | user_views <- try(lapply(
25 | X = user_repo$name,
26 | FUN = function(x) {
27 | dat <- gh("/repos/:owner/:repo/traffic/views", owner = user, repo = x, .limit = Inf)
28 | if (length(dat$views) == 0) {
29 | return(NULL)
30 | } else {
31 | dat <- rbindlist(dat$views)
32 | dat$repo <- x
33 | dat
34 | }
35 | }
36 | ), silent = TRUE)
37 | if ("try-error" %in% class(user_views)) {
38 | user_views <- data.table(repo = character(0), date = character(0), count = numeric(0))
39 | } else {
40 | user_views <- rbindlist(user_views)
41 | user_views[, date := as.Date(substr(timestamp, 1, 10))]
42 | setorder(user_views, repo, date)
43 | user_views <- user_views[CJ(repo = user_repo$name, date = unique(date)), on = c("repo", "date")]
44 | user_views[is.na(count), count := 0]
45 | user_views <- user_views[, list(repo, date, count)]
46 | }
47 | return(list(user_repo = user_repo, user_views = user_views))
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/gh-dashboard/global.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : GitHub dashboard - Global
5 | # By : dreamRs
6 | # Date : 2018-10-30 (update: 2022-01-27)
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 | if (identical(Sys.getenv("GITHUB_PAT"), "")) {
12 | warning("Without a GitHub PAT, some features won't be available")
13 | }
14 |
15 |
16 | # Packages ----------------------------------------------------------------
17 |
18 | library(data.table)
19 | library(gh)
20 | library(ggplot2)
21 | library(shinyWidgets)
22 | library(phosphoricons)
23 | library(shinyjs)
24 |
25 |
26 |
27 | # Funs --------------------------------------------------------------------
28 |
29 | source("funs/utils.R")
30 |
31 |
--------------------------------------------------------------------------------
/gh-dashboard/screenshot-old.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/gh-dashboard/screenshot-old.png
--------------------------------------------------------------------------------
/gh-dashboard/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/gh-dashboard/screenshot.png
--------------------------------------------------------------------------------
/gh-dashboard/server.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : GitHub dashboard - Server
5 | # By : dreamRs
6 | # Date : 2018-10-30 (update: 2022-01-27)
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 | function(input, output, session) {
12 |
13 | observe({
14 | query <- getQueryString()
15 | if (!is.null(query$q)) {
16 | updateSearchInput(session = session, inputId = "gh_user2", value = query$q, trigger = TRUE)
17 | }
18 | }, priority = 1)
19 |
20 | gh_user <- reactiveValues(x = NULL)
21 | observeEvent(input$gh_user1, {
22 | gh_user$x <- input$gh_user1
23 | })
24 | observeEvent(input$gh_user2, {
25 | gh_user$x <- input$gh_user2
26 | })
27 |
28 | gh_datas <- reactiveValues(
29 | user = NULL,
30 | infos = NULL,
31 | referer = NULL,
32 | views = NULL
33 | )
34 |
35 | observeEvent(gh_user$x, {
36 | req(gh_user$x)
37 | user_data <- try(gh("/users/:username", username = gh_user$x), silent = TRUE)
38 | if (is.null(user_data) | inherits(user_data, "try-error")) {
39 | show(id = "alert-gh-user")
40 | gh_datas$infos <- NULL
41 | gh_datas$views <- NULL
42 | gh_datas$user <- NULL
43 | n_stars <- n_issues <- n_repos <- 0
44 | } else {
45 | hide(id = "alert-gh-user")
46 | gh_datas$user <- user_data
47 | res_infos <- gh_infos(gh_user$x)
48 | gh_datas$infos <- res_infos$user_repo
49 | gh_datas$views <- res_infos$user_views
50 | n_stars <- sum(gh_datas$infos$stargazers_count)
51 | n_issues <- sum(gh_datas$infos$open_issues)
52 | n_repos <- nrow(gh_datas$infos)
53 | }
54 | updateStatiCard(id = "n_stars", value = format(n_stars, width = 9))
55 | updateStatiCard(id = "n_issues", value = n_issues)
56 | updateStatiCard(id = "n_repos", value = n_repos)
57 | })
58 |
59 | output$user_avatar <- renderUI({
60 | req(gh_datas$user)
61 | tagList(
62 | tags$img(src = gh_datas$user$avatar_url, width = 109, height = 109),
63 | tags$div(
64 | style = "display: table-cell; vertical-align: middle; padding-left: 20px;",
65 | tags$span(gh_datas$user$bio), tags$br(),
66 | tags$a(href = gh_datas$user$blog, ph("link"), gh_datas$user$blog), tags$br(),
67 | tags$a(href = gh_datas$user$html_url, ph("git-branch"), gh_datas$user$html_url)
68 | )
69 | )
70 | })
71 |
72 | output$plot_stargazers <- renderPlot({
73 | req(gh_datas$infos)
74 | data_stargazers <- gh_datas$infos
75 | ggplot(data = tail(data_stargazers, 20)) +
76 | aes(name, stargazers_count, label = stargazers_count) +
77 | geom_col(fill = "#112446") +
78 | geom_text(hjust = -0.25, family = "serif", size = 4) +
79 | coord_flip() +
80 | scale_y_continuous(expand = expansion(c(0, 0.1))) +
81 | labs(
82 | title = "Number of stargazers by repo",
83 | x = NULL, y = "Number of stars"
84 | ) +
85 | theme_minimal()
86 | })
87 |
88 |
89 | output$plot_visitors <- renderPlot({
90 | # req(gh_datas$views)
91 | validate(need(
92 | nrow(gh_datas$views) > 0,
93 | "You must register a GitHub PAT to see this chart, and this work only for your own username."
94 | ), errorClass = "no-pat")
95 | data_views <- gh_datas$views
96 | ggplot(data = tail(data_views, 20*15)) +
97 | aes(x = date, y = repo, size = count, color = count) +
98 | scale_size_continuous(range = c(0, 15)) +
99 | scale_x_date(date_breaks = "2 days") +
100 | scale_color_gradient(low = "#112446") +
101 | scale_y_discrete(expand = expansion(c(0.06, 0.06))) +
102 | guides(color = guide_legend(title = "Views"), size = guide_legend(title = "Views")) +
103 | geom_point() +
104 | theme_minimal() +
105 | labs(
106 | title = "Visitors by repo",
107 | x = "Date", y = "Repo"
108 | )
109 | })
110 |
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/gh-dashboard/ui.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : GitHub dashboard - UI
5 | # By : dreamRs
6 | # Date : 2018-10-30 (update: 2022-01-27)
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 | fluidPage(
12 |
13 | tags$head(
14 | tags$link(href="styles.css", rel="stylesheet", type="text/css")
15 | ),
16 |
17 | useShinyjs(),
18 |
19 | fluidRow(
20 |
21 | column(
22 | width = 10, offset = 1,
23 |
24 | tags$div(
25 | class = "title",
26 | tags$br(),
27 | tags$h1("GitHub dashboard", class = "titre"),
28 | tags$h2("Retrieve information about a GitHub user/organisation via the GitHub API", class = "soustitre"),
29 | tags$br(),
30 |
31 | tags$span(ph("github-logo"), class = "main-icon")
32 | ),
33 |
34 | fluidRow(
35 | column(
36 | width = 4,
37 | selectizeInput(
38 | inputId = "gh_user1",
39 | label = "GitHub username:",
40 | choices = "",
41 | width = "100%",
42 | options = list(
43 | placeholder = "Search a GitHub user via API",
44 | valueField = "login",
45 | labelField = "login",
46 | searchField = "login",
47 | sortField = "score",
48 | persist = FALSE,
49 | loadThrottle = "300",
50 | options = list(),
51 | create = FALSE,
52 | preload = "focus",
53 | render = I("{
54 | option: function(item, escape) {
55 | return '
' +
56 | '
' + escape(item.login) + '' +
57 | '
';
58 | }
59 | }"),
60 | load = I("function(query, callback) {
61 | if (!query.length) return callback();
62 | $.ajax({
63 | url: 'https://api.github.com/search/users',
64 | type: 'GET',
65 | data: {
66 | q: encodeURIComponent(query)
67 | },
68 | error: function() {
69 | callback();
70 | },
71 | success: function(res) {
72 | callback(res.items);
73 | }
74 | });
75 | }")
76 | )
77 | )
78 | ),
79 | column(
80 | width = 4,
81 | searchInput(
82 | inputId = "gh_user2",
83 | label = "Or enter directly a username:",
84 | value = "dreamRs",
85 | btnSearch = ph("magnifying-glass"),
86 | btnReset = ph("x"),
87 | width = "100%"
88 | )
89 | )
90 | ),
91 | tags$div(
92 | id = "alert-gh-user", style = "display: none;",
93 | class = "alert alert-danger",
94 | tags$b(ph("warning"), "Error:", "username doesn't seems to be a valid GitHub user/org.")
95 | ),
96 |
97 | fluidRow(
98 | column(
99 | width = 3,
100 | uiOutput(outputId = "user_avatar", style = "display: table;")
101 | ),
102 | column(
103 | width = 3,
104 | statiCard(
105 | value = 0,
106 | subtitle = tags$b("Total stars"),
107 | background = "#112446",
108 | color = "#FFF",
109 | animate = TRUE,
110 | icon = ph_i("star", weight = "regular"),
111 | id = "n_stars"
112 | )
113 | ),
114 | column(
115 | width = 3,
116 | statiCard(
117 | value = 0,
118 | subtitle = tags$b("Open issues"),
119 | background = "#112446",
120 | color = "#FFF",
121 | animate = TRUE,
122 | icon = ph_i("warning-circle", weight = "regular"),
123 | id = "n_issues"
124 | )
125 | ),
126 | column(
127 | width = 3,
128 | statiCard(
129 | value = 0,
130 | subtitle = tags$b("Number of repos"),
131 | background = "#112446",
132 | color = "#FFF",
133 | animate = TRUE,
134 | icon = ph_i("book", weight = "regular"),
135 | id = "n_repos"
136 | )
137 | )
138 | ),
139 | fluidRow(
140 | column(
141 | width = 6,
142 | addSpinner(
143 | plotOutput(outputId = "plot_stargazers", height = "500px")
144 | )
145 | ),
146 | column(
147 | width = 6,
148 | addSpinner(
149 | plotOutput(outputId = "plot_visitors", height = "500px")
150 | )
151 | )
152 | ),
153 | br()
154 | )
155 | )
156 | )
157 |
--------------------------------------------------------------------------------
/gh-dashboard/www/styles.css:
--------------------------------------------------------------------------------
1 |
2 | .shiny-output-error-no-pat {
3 | text-align: center;
4 | line-height: 500px;
5 | background: #FFF;
6 | }
7 |
8 | .titre {
9 | font-family: Georgia, "Times New Roman", Times, serif;
10 | font-size:28px;
11 | margin-top: 5px; margin-bottom: 0px;
12 | text-align: left;
13 | font-weight: normal;
14 | color: #222;
15 | }
16 |
17 | .soustitre {
18 | font-family: "Lucida Grande", Tahoma;
19 | font-size: 14px;
20 | font-weight: lighter;
21 | font-variant: normal;
22 | text-transform: uppercase;
23 | color: #666666;
24 | margin-top: 10px;
25 | text-align: left;
26 | letter-spacing: 0.3em;
27 | }
28 |
29 |
30 | body {
31 | font-family: Georgia, "Times New Roman", Times, serif;
32 | }
33 |
34 |
35 | .icon-white {
36 | color: #FFF;
37 | }
38 |
39 |
40 | #magnifying-glass
41 | {
42 | font-size: 30em; /* This controls the size. */
43 | display: inline-block;
44 | width: 0.4em;
45 | height: 0.4em;
46 | border: 0.1em solid red;
47 | position: fixed;
48 | top: 10px;
49 | left: 10px;
50 | border-radius: 0.35em;
51 | }
52 | #magnifying-glass::before
53 | {
54 | content: "";
55 | display: inline-block;
56 | position: absolute;
57 | right: -0.25em;
58 | bottom: -0.1em;
59 | border-width: 0;
60 | background: red;
61 | width: 0.35em;
62 | height: 0.08em;
63 | -webkit-transform: rotate(45deg);
64 | -moz-transform: rotate(45deg);
65 | -ms-transform: rotate(45deg);
66 | -o-transform: rotate(45deg);
67 | }
68 |
69 |
70 |
71 | .main-icon {
72 | position: absolute;
73 | top: -35px;
74 | right: 15px;
75 | color: #F2F2F2;
76 | font-size: 1100%;
77 | z-index: -1;
78 | }
79 |
80 | .dreamrs {
81 | background-image:url(logo_dreamRs_couleur.png);
82 | background-repeat:no-repeat;
83 | background-position:right bottom;
84 | background-size: 156px 100px;
85 | }
86 |
87 |
88 | .progress {
89 | margin-bottom: 3px !important;
90 | }
91 | .progress-bar-nuclear {
92 | background-color: #f8ca4c;
93 | }
94 | .progress-bar-fossil {
95 | background-color: #848484;
96 | }
97 | .progress-bar-renewable {
98 | background-color: #088A08;
99 | }
100 |
101 |
102 | .material-switch > input[type="checkbox"]:checked + label::after {
103 | background: #112446;
104 | }
105 |
106 |
107 | .btn-dreamrs {
108 | background-color: #112446;
109 | color: #fff;
110 | border-color: #112446;
111 | }
112 |
113 | .btn-dreamrs:hover {
114 | color: #fff;
115 | }
116 |
117 | .btn-dreamrs.active {
118 | color: #112446;
119 | background-color: #fff;
120 | border-color: #112446;
121 | }
122 |
123 |
124 | /* Charts */
125 |
126 | .plot-spin {
127 | background: #FFFFFF;
128 | }
129 |
130 | .bb-line-forecast {
131 | stroke-width: 2px;
132 | }
133 |
134 | .bb-line-observed {
135 | stroke-dasharray: 12 4; stroke-width: 2px;
136 | }
137 |
--------------------------------------------------------------------------------
/olympic-medals/R/data.R:
--------------------------------------------------------------------------------
1 | filter_discipline <- function(data, discipline_v = NULL) {
2 | if (is.null(discipline_v)) {
3 | return(data)
4 | }
5 |
6 | rtn_x <- data %>%
7 | filter(discipline_title %in% discipline_v)
8 |
9 | return(rtn_x)
10 | }
11 |
12 | filter_slug_game <- function(data, slug_game_v = NULL) {
13 | if (is.null(slug_game_v)) {
14 | return(data)
15 | }
16 |
17 | rtn_x <- data %>%
18 | filter(slug_game %in% slug_game_v)
19 |
20 | return(rtn_x)
21 | }
22 |
23 | filter_top <- function(data, top_n = 10) {
24 | rtn_x <- data %>%
25 | filter(country_name %in% unique(country_name)[seq_len(top_n)])
26 | return(rtn_x)
27 | }
28 |
29 | filter_medal_type <- function(data, medal_type_v) {
30 | # if (medal_type_v == "All"){
31 | # medal_type_v <- c("BRONZE", "SILVER", "GOLD")
32 | # }
33 | rtn_x <- data %>%
34 | filter(medal_type %in% medal_type_v)
35 | return(rtn_x)
36 | }
37 |
38 | medal_calc <- function(data) {
39 | rtn_x <- data %>%
40 | group_by(country_name, medal_type) %>%
41 | summarise(n_medal = n()) %>%
42 | mutate(n_tot = sum(n_medal)) %>%
43 | arrange(-n_tot) %>%
44 | ungroup()
45 | return(rtn_x)
46 | }
47 |
--------------------------------------------------------------------------------
/olympic-medals/R/visualisation.R:
--------------------------------------------------------------------------------
1 | visualisation_medal <- function(x) {
2 | col_medailles <- c("BRONZE" = "#996B4F", "SILVER" = "#969696", "GOLD" = "#9F8F5E")
3 | cur_sub_title <- c(
4 | "GOLD" = " Gold ",
5 | "SILVER" = " Silver ",
6 | "BRONZE" = " Bronze "
7 | )
8 | cur_sub_title <- cur_sub_title[sort(match(x = unique(x$medal_type), table = names(cur_sub_title)))]
9 | if (length(cur_sub_title) > 1) {
10 | cur_sub_title <- append(x = cur_sub_title, value = "and", after = (length(cur_sub_title) - 1))
11 | }
12 | cur_sub_title <- c("Number of", cur_sub_title)
13 | cur_sub_title <- c(cur_sub_title, "medals")
14 | x$medal_type <- factor(x$medal_type, levels = names(col_medailles))
15 | ggplot(data = x, mapping = aes(
16 | y = reorder(country_name, n_tot), x = n_medal,
17 | fill = factor(medal_type)
18 | )) +
19 | geom_col() +
20 | scale_fill_manual(values = col_medailles, breaks = names(col_medailles)[length(col_medailles):1]) +
21 | labs(
22 | title = "An overview of olympic medals",
23 | subtitle = paste(cur_sub_title, collapse = ""),
24 | x = "number of medals",
25 | fill = "medal type"
26 | ) +
27 | theme_minimal() +
28 | theme(text = element_text(size = 15)) +
29 | theme(
30 | axis.title.y = element_blank(),
31 | plot.subtitle = element_markdown()
32 | ) +
33 | guides(fill = "none")
34 | }
35 |
36 | table_medal <- function(data) {
37 | columns <- list(
38 | country_name = colDef(
39 | name = "Country Name"
40 | ),
41 | n_tot = colDef(
42 | name = "Total Medals"
43 | )
44 | )
45 | if (hasName(data, "BRONZE")) {
46 | columns$BRONZE <- colDef(
47 | name = "BRONZE",
48 | html = TRUE,
49 | header = function(x) {
50 | tags$div(icon("medal"), "BRONZE", style = "color: #996B4F;")
51 | }
52 | )
53 | }
54 | if (hasName(data, "SILVER")) {
55 | columns$SILVER <- colDef(
56 | name = "SILVER",
57 | html = TRUE,
58 | header = function(x) {
59 | tags$div(icon("medal"), "SILVER", style = "color: #969696")
60 | }
61 | )
62 | }
63 | if (hasName(data, "GOLD")) {
64 | columns$GOLD <- colDef(
65 | name = "GOLD",
66 | html = TRUE,
67 | header = function(x) {
68 | tags$div(icon("medal"), "GOLD", style = "color: #9F8F5E")
69 | }
70 | )
71 | }
72 | reactable(
73 | data = data,
74 | columns = columns
75 | )
76 | }
77 |
--------------------------------------------------------------------------------
/olympic-medals/app.R:
--------------------------------------------------------------------------------
1 | library("shiny")
2 | library("shinydashboard")
3 | library("shinyWidgets")
4 | library("ggplot2")
5 | library("ggthemes")
6 | library("bslib")
7 | library("dplyr")
8 | library("data.table")
9 | library("reactable")
10 | library("tidyr")
11 | library("ggtext")
12 | source("R/data.R")
13 | source("R/visualisation.R")
14 |
15 | medals_summer <- readRDS(file = "datas/medals_summer.rds")
16 |
17 |
18 | ui <- fluidPage(
19 | title = "R-Olympics",
20 | theme = bs_theme(
21 | version = 5,
22 | preset = "bootstrap",
23 | bg = "#FFFFFF",
24 | fg = "#000000",
25 | primary = "#E3E3E3",
26 | secondary = "#000000",
27 | base_font = "Maven Pro"
28 | ),
29 | tags$head(
30 | tags$link(
31 | rel = "icon", type = "image/png", sizes = "32x32",
32 | href = "rings.png"
33 | )
34 | ),
35 | setBackgroundImage(
36 | src = "pic2.jpg"
37 | ),
38 | fluidRow(
39 | class = "mt-4",
40 | column(
41 | width = 8,
42 | offset = 2,
43 | card(
44 | tags$div(
45 | tags$img(
46 | src = "rings.jpg",
47 | width = 200,
48 | height = 100
49 | ),
50 | tags$h2("An overview of olympic medals"),
51 | class = "text-center"
52 | ),
53 | fluidRow(
54 | column(
55 | width = 5,
56 | virtualSelectInput(
57 | inputId = "discipline",
58 | label = "Select discipline:",
59 | choices = unique(medals_summer$discipline_title),
60 | multiple = TRUE,
61 | selected = NULL,
62 | width = "100%"
63 | )
64 | ),
65 | column(
66 | width = 5,
67 | virtualSelectInput(
68 | inputId = "summer_og",
69 | label = "Select game edition:",
70 | choices = unique(medals_summer$slug_game),
71 | multiple = TRUE,
72 | selected = NULL,
73 | width = "100%"
74 | )
75 | ),
76 | column(
77 | width = 2,
78 | tags$div(
79 | class = "shiny-input-container",
80 | tags$label(
81 | class = "control-label invisible",
82 | "Settings"
83 | ),
84 | dropMenu(
85 | actionButton(
86 | inputId = "btn",
87 | label = "Settings",
88 | style = "color: black; background-color: white; border-color: black",
89 | class = "btn-outline-primary",
90 | icon = icon("medal"),
91 | width = "100%"
92 | ),
93 | checkboxGroupButtons(
94 | inputId = "medal_type",
95 | label = "Select medal type:",
96 | choiceValues = unique(medals_summer$medal_type),
97 | direction = "vertical",
98 | choiceNames = list(
99 | tags$span(icon("medal"), "GOLD", style = "color: #9F8F5E;"),
100 | tags$span(icon("medal"), "SILVER", style = "color: #969696"),
101 | tags$span(icon("medal"), "BRONZE", style = "color: #996B4F")
102 | ),
103 | selected = unique(medals_summer$medal_type),
104 | width = "100%",
105 | status = "outline-primary"
106 | ),
107 | numericInput(
108 | inputId = "top",
109 | label = "Number of countries displayed:",
110 | value = 10,
111 | min = 1,
112 | max = length(unique(medals_summer$country_name)),
113 | width = "100%"
114 | ),
115 | placement = "bottom-start",
116 | theme = "light",
117 | padding = "0px"
118 | )
119 | )
120 | )
121 | ),
122 | plotOutput(outputId = "graph", height = "auto"),
123 | tags$br(),
124 | reactableOutput("table"),
125 | tags$br(),
126 | card(
127 | card_header("Data: Source & Download"),
128 | card_body(
129 | tags$div(
130 | icon("save", style = "color: black"),
131 | downloadLink(
132 | outputId = "downloadData",
133 | label = "Download Data",
134 | style = "color: blue;"
135 | )
136 | ),
137 | tags$a(
138 | icon("link", style = "color: black"),
139 | "https://www.kaggle.com/datasets/piterfm/olympic-games-medals-19862018",
140 | href = " https://www.kaggle.com/datasets/piterfm/olympic-games-medals-19862018",
141 | style = "color: blue;"
142 | )
143 | )
144 | )
145 | )
146 | )
147 | )
148 | )
149 |
150 | server <- function(input, output) {
151 | data_in_pre <- reactive({
152 | data_step <- filter_discipline(
153 | data = medals_summer,
154 | discipline_v = input$discipline
155 | ) %>%
156 | filter_slug_game(slug_game_v = input$summer_og) %>%
157 | filter_medal_type(medal_type_v = input$medal_type) %>%
158 | medal_calc()
159 | })
160 | data_in <- reactive({
161 | data_in_pre() %>%
162 | filter_top(top_n = input$top)
163 | })
164 | data_in_pivot <- reactive({
165 | data_step <- data_in_pre() %>%
166 | pivot_wider(names_from = medal_type, values_from = n_medal) %>%
167 | select(1:2, any_of(c("GOLD", "SILVER", "BRONZE")))
168 | })
169 | output$table <- renderReactable({
170 | table_medal(data_in_pivot())
171 | })
172 | hght <- reactive({
173 | 50 + 30 * input$top
174 | })
175 | output$graph <- renderPlot(
176 | {
177 | visualisation_medal(x = data_in())
178 | },
179 | height = hght
180 | )
181 | output$downloadData <- downloadHandler(
182 | filename = function() {
183 | "data-olympic.csv"
184 | },
185 | content = function(file) {
186 | write.csv(data_in(), file)
187 | }
188 | )
189 | }
190 |
191 | shinyApp(ui = ui, server = server)
192 |
--------------------------------------------------------------------------------
/olympic-medals/datas/medals_summer.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/olympic-medals/datas/medals_summer.rds
--------------------------------------------------------------------------------
/olympic-medals/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/olympic-medals/screenshot.png
--------------------------------------------------------------------------------
/olympic-medals/www/pic2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/olympic-medals/www/pic2.jpg
--------------------------------------------------------------------------------
/olympic-medals/www/rings.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/olympic-medals/www/rings.jpg
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/datas/NVALDTOT_STAT_CATJOUR_LIGNE.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/datas/NVALDTOT_STAT_CATJOUR_LIGNE.rds
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/datas/info_ligne.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/datas/info_ligne.rds
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/datas/lignes_metro.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/datas/lignes_metro.rds
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/datas/plan_metro.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/datas/plan_metro.rds
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/datas/profil_horaire_global.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/datas/profil_horaire_global.rds
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/datas/profil_horaire_ligne.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/datas/profil_horaire_ligne.rds
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/datas/validation_metro.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/datas/validation_metro.rds
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/funs/box_icon.R:
--------------------------------------------------------------------------------
1 |
2 | box_icon <- function(...) {
3 | tags$div(
4 | class="list-group",
5 | lapply(
6 | X = list(...),
7 | FUN = function(x) {
8 | tags$span(
9 | class="list-group-item",
10 | tags$span(icon(x$icon, class = "fa-fw fa-lg"), style = paste("color: ", x$col)),
11 | HTML(" "),
12 | x$text
13 | )
14 | }
15 | )
16 | )
17 | }
18 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/funs/descriptif_application.R:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | descriptif_application <- function() {
5 | column(
6 | width = 12,
7 | align = "left",
8 | tags$div(
9 | class = "dreamrs",
10 | tags$b("Info :"),
11 | tags$ul(
12 | tags$li("L\'application d\u00e9crit le traffic du m\u00e9tro parisien pour l\'ann\u00e9e 2017 par station, ligne et type de jour s\u00e9lectionn\u00e9.
13 | Elle d\u00e9crit aussi les caract\u00e9ristiques des diff\u00e9rentes lignes du m\u00e9tro parisien."),
14 | tags$li("Le nombre de validations calcul\u00e9 ne comptabilise que les entr\u00e9es sur le r\u00e9seau avec une carte d\'abonnement."),
15 | tags$li("Les validations avec un ticket ainsi que les validations de sortie ne sont donc pas prises en compte.")
16 | ),
17 | tags$b("Donn\u00e9es :"),
18 | tags$ul(
19 | tags$li(
20 | "L\' application a \u00e9t\u00e9 cr\u00e9\u00e9e \u00e0 partir des donn\u00e9es Open du STIF : ",
21 | tags$a("OpenData stif info",
22 | href = "https://opendata.stif.info/")
23 | ),
24 | tags$li("Les informations sur les lignes viennent de Wikipedia")
25 | ),
26 | tags$b("Packages :"),
27 | tags$ul(
28 | tags$li(tags$a("shiny", href = "https://shiny.rstudio.com/"), ": pour l\'application"),
29 | tags$li(tags$a("bs4Dash", href = "https://github.com/RinteRface/bs4Dash"), ", ", ": pour customiser l\'apparence de l\'application"),
30 | tags$li(tags$a("leaflet", href = "https://rstudio.github.io/leaflet/"),
31 | ": pour cr\u00e9er la carte"),
32 | tags$li(tags$a("leaflet.extras", href = "https://github.com/bhaskarvk/leaflet.extras"),
33 | ": pour rechercher un endroit sur la carte"),
34 | tags$li(tags$a("dplyr", href = "https://github.com/tidyverse/dplyr"),
35 | ": pour manipuler les donn\u00e9es"),
36 | tags$li(tags$a("billboarder", href = "https://github.com/dreamRs/billboarder"),
37 | ": pour les graphiques du profil de fr\u00e9quentation horaire"),
38 | tags$li(tags$a("stringr", href = "https://github.com/tidyverse/stringr"),
39 | ": pour les cha\u00eenes de caract\u00e8res"),
40 | tags$li(tags$a("scales", href = "https://github.com/r-lib/scales"),
41 | ": pour normaliser le vecteur Nombre de validation afin d\'ajuster la taille des points (stations) sur la carte")
42 | ),
43 | tags$b("Auteur :"), # tags$b : titre
44 | tags$div("Cette application a \u00e9t\u00e9 d\u00e9velopp\u00e9e par Philippine Rheins ",
45 | tags$a(class = "btn btn-default", icon("twitter"), "@Philippine",
46 | href = "https://twitter.com/PhilippineRs", style = "background-color: #1DA1F2; color: #FFF;"
47 | )),
48 | tags$div("Pour en voir d\'autres, n\'h\u00e9sitez pas \u00e0 visiter notre site : ",
49 | tags$a("dreamrs.fr", href = "https://www.dreamrs.fr/")),
50 | tags$div(
51 | "ou \u00e0 nous suivre sur Twitter : ",
52 | tags$a(
53 | class = "btn btn-default", icon("twitter"), "@dreamRs",
54 | href = "https://twitter.com/dreamRs_fr", style = "background-color: #1DA1F2; color: #FFF;"
55 | )
56 | )
57 | )
58 | )
59 | }
60 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/funs/graph_profil_horaire.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | #' Graphique pour representer les profils horaires de validation
4 | #'
5 | #' @param data un \code{data.frame} avec les donnees de validation
6 | #' @param jour Jour considere
7 | #' @param title Titre du graphique
8 | #' @param ylab Titre de l'axe des abscisses
9 | #' @param col Couleur des barres
10 | #'
11 | #'
12 | #' @examples
13 | #'
14 | #' library(dplyr)
15 | #' library(highcharter)
16 | #'
17 | #' profil_horaire_ligne <- readRDS("Datas/profil_horaire_ligne.rds")
18 | #' phl1 <- profil_horaire_ligne %>%
19 | #' filter(LIGNE == "1") %>%
20 | #' rename(VALD = NB_VALD)
21 | #'
22 | #'
23 | #'
24 | #' graph_profil_hor(data = phl1)
25 | #'
26 | #' graph_profil_hor(data = phl1, jour = "vacances", title = "Vacances")
27 | #' graph_profil_hor(data = phl1, jour = "weekend", title = "Week-end")
28 | #'
29 | graph_profil_hor <- function(data,
30 | jour = "vacances",
31 | title = "Vacances",
32 | ylab = "Nbre de validation",
33 | col = "#18bc9c",
34 | percent = FALSE) {
35 |
36 | max_yaxis <- max(data$VALD)
37 | breaks_yaxis <- scales::pretty_breaks()(c(0, max_yaxis))[-1]
38 |
39 | if (percent) {
40 | format_y_axis <- suffix("%")
41 | tooltip_format <- "d[0].value + '%'"
42 | } else {
43 | format_y_axis <- htmlwidgets::JS("function(x) {return d3.format('.2s')(x);}")
44 | tooltip_format <- "d3.format('\u00a0>7,')(d[0].value)"
45 | }
46 |
47 | data <- data %>%
48 | filter(type_jour == jour) %>%
49 | mutate(COLOR = col) %>%
50 | mutate(TRNC_HORR = stringr::str_remove(TRNC_HORR, "-\\d{1,2}h"))
51 |
52 | billboarder(data = data) %>%
53 | bb_barchart(mapping = bbaes(x = TRNC_HORR, y = VALD), color = col) %>%
54 | bb_y_grid(show = TRUE) %>%
55 | bb_grid(front = TRUE) %>%
56 | bb_x_axis(tick = list(multiline = FALSE)) %>%
57 | bb_y_axis(
58 | show = jour == "vacances",
59 | inner = TRUE,
60 | max = max_yaxis,
61 | tick = list(
62 | text = list(
63 | position = list(x = 0, y = 10)
64 | ),
65 | format = format_y_axis,
66 | values = breaks_yaxis
67 | ),
68 | label = list(text = ylab, position = "outer-top")
69 | ) %>%
70 | bb_tooltip(
71 | linked = list(name = "tooltip-profil-horaire"),
72 | contents = htmlwidgets::JS(
73 | paste0(
74 | "function(d, defaultTitleFormat, defaultValueFormat, color) {
75 | var lib = ['0h - 2h','2h- 4h','4h - 6h','6h - 8h','8h - 10h','10h - 12h','12h - 14h','14h - 16h','16h - 18h','18h - 20h','20h - 22h','22h - 0h'];
76 | //console.log(d);
77 | d3.formatDefaultLocale({'decimal': ',',
78 | 'thousands': '\u00a0',
79 | 'grouping': [3],
80 | 'currency': ['', '\u00a0€'],
81 | 'percent': '\u202f%'});
82 |
83 | return lib[d[0].index] + ': ' + ", tooltip_format, " + '';}"
84 | )
85 | ),
86 | position = htmlwidgets::JS(
87 | "function(data, width, height, element) {console.log(element) ; return {top: 0, right: 100};}"
88 | )
89 | ) %>%
90 | bb_legend(show = FALSE) %>%
91 | bb_labs(title = title) %>%
92 | bb_add_style(".bb-tooltip-container" = "right: 10px; border: 1px solid #0073b7; border-radius: 5px; padding: 4px;")
93 | }
94 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/funs/import_validation.R:
--------------------------------------------------------------------------------
1 |
2 | #' Import des données de validation du STIF
3 | #'
4 | #' @param file chemin du fichier csv à importer.
5 | #' @param format_jour format a appliquer sur la date par défaut le numéro et le jour de la semaine.
6 | #'
7 | #' @return renvoie un data.frame
8 | #' @export
9 | #'
10 | #' @examples
11 | #' mydata <- import_validation("chemin/fichier.csv")
12 |
13 | import_validation <- function(file, format_jour = "%u-%A") {
14 | if (!file.exists(file)) {
15 | stop("Ce fichier n'existe pas ! ")
16 | }
17 | if (!require("dplyr")) {
18 | stop("dplyr doit etre installe")
19 | }
20 | data <- read.table(file = file,
21 | sep = ";",
22 | header = TRUE,
23 | colClasses = "character",
24 | quote = "",
25 | stringsAsFactors = FALSE,
26 | encoding = 'UTF-8')
27 | data <- data %>%
28 | mutate(JOUR = as.Date(JOUR),
29 | JOUR_SEMAINE = format(JOUR, format = format_jour)) %>%
30 | mutate(NB_VALD = gsub(pattern = "[^0-9]", replacement = "", x = NB_VALD),
31 | NB_VALD = as.numeric(NB_VALD)) %>%
32 | arrange(JOUR)
33 | return(data)
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/global.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : RATP validations - Global
5 | # By : Philippine (adapted by D .Granjon)
6 | # Date : 2018-08-07
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 | # Packages ----------------------------------------------------------------
12 |
13 | library(dplyr)
14 | library(shiny)
15 | #library(shinydashboard)
16 | #library(shinythemes)
17 | library(shinyWidgets)
18 | library(leaflet)
19 | library(leaflet.extras)
20 | library(stringr)
21 | library(scales)
22 | library(billboarder)
23 | library(sf)
24 | library(bs4Dash)
25 | library(shinyjs)
26 |
27 |
28 | # funs --------------------------------------------------------------------
29 |
30 | source("funs/box_icon.R")
31 | source("funs/graph_profil_horaire.R")
32 | source("funs/descriptif_application.R")
33 |
34 |
35 |
36 | # datas -------------------------------------------------------------------
37 |
38 | lignes_metro <- readRDS("datas/lignes_metro.rds")
39 | info_ligne <- readRDS("datas/info_ligne.rds")
40 | NVALDTOT_STAT_CATJOUR_LIGNE <- readRDS("datas/NVALDTOT_STAT_CATJOUR_LIGNE.rds")
41 | validation <- readRDS("datas/validation_metro.rds")
42 | profil_horaire_ligne <- readRDS("datas/profil_horaire_ligne.rds")
43 | profil_horaire_global <- readRDS("datas/profil_horaire_global.rds")
44 | plan_metro <- readRDS("datas/plan_metro.rds")
45 | metrolines <- c("1","2","3","3bis","4","5","6","7","7bis","8","9","10","11","12","13","14")
46 | validation_ligne <- inner_join(
47 | x = lignes_metro %>% select(-NOM_ARRET),
48 | y = validation,
49 | by = "ID_ARRET"
50 | )
51 |
52 | couleur_ligne <- data.frame(
53 | LIGNE = c("1", "2", "3", "3b", "4", "5", "6", "7", "7b", "8", "9", "10", "11", "12", "13", "14"),
54 | code_hexa = c("#FFCD00","#003CA6","#837902","#6EC4E8","#CF009E","#FF7E2E","#6ECA97","#FA9ABA",
55 | "#6ECA97","#E19BDF","#B6BD00","#C9910D","#704B1C","#007852","#6EC4E8","#62259D"),
56 | stringsAsFactors = FALSE
57 | )
58 | couleur_ligne$LIGNE <- ordered(x = couleur_ligne$LIGNE, couleur_ligne$LIGNE)
59 |
60 | pal <- colorFactor(
61 | levels = levels(couleur_ligne$LIGNE),
62 | palette = couleur_ligne$code_hexa
63 | )
64 |
65 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/readme.md:
--------------------------------------------------------------------------------
1 | # bs4Dash version
2 | This version uses [bs4Dash](https://github.com/RinteRface/bs4Dash) from github,
3 | that is v0.6.0.9000 (whereas CRAN is 0.5.0).
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/ui.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : RATP validations - UI
5 | # By : Philippine (adapted by D .Granjon)
6 | # Date : 2018-08-07
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 | bs4DashPage(
11 | navbar = bs4DashNavbar(
12 | tagList(
13 | pickerInput(
14 | inputId = "choix_ligne",
15 | width = NULL,
16 | options = list(style = "btn-primary"),
17 | multiple = FALSE,
18 | choices = c("ALL",levels(lignes_metro$LIGNE)),
19 | choicesOpt = list(
20 | content = c(
21 | sprintf("
- Choisissez une ligne : "),
22 | sprintf("
Ligne %s",
23 | metrolines, metrolines)
24 | )
25 | ),
26 | selected = "Choisissez une ligne"
27 | ),
28 | tags$div(
29 | style = "display: inline-block; margin-left: 10px;",
30 | checkboxGroupInput(
31 | inputId = "type_jour",
32 | label = NULL,
33 | width = NULL,
34 | choices = list("Vacances" = "vacances", "Week-end" = "weekend", "Jour ouvr\u00e9" = "Jour ouvre"),
35 | selected = c("Jour ouvre", "weekend", "vacances"),
36 | inline = TRUE
37 | )
38 | )
39 | )
40 | ),
41 | sidebar = bs4DashSidebar(
42 | skin = "light",
43 | status = "primary",
44 | title = tags$small("Le M\u00e9tro parisien en 2017"),
45 | src = "RATP.svg",
46 | elevation = 3,
47 | opacity = 0.8,
48 | bs4SidebarMenu(
49 | bs4SidebarMenuItem(
50 | "Tableau de bord",
51 | tabName = "dashboard",
52 | icon = "sliders"
53 | ),
54 | bs4SidebarMenuItem(
55 | "A propos de l\'application",
56 | tabName = "about",
57 | icon = "info"
58 | )
59 | )
60 | ),
61 | controlbar = NULL,
62 | footer = bs4DashFooter(
63 | copyrights = tagList(
64 | tags$a(
65 | class = "btn btn-default",
66 | icon("twitter"),
67 | "@Philippine",
68 | href = "https://twitter.com/PhilippineRs",
69 | style = "background-color: #1DA1F2; color: #FFF;"
70 | ),
71 | tags$a(
72 | class = "btn btn-default",
73 | icon("twitter"),
74 | "@dreamRs",
75 | href = "https://twitter.com/dreamRs_fr",
76 | style = "background-color: #1DA1F2; color: #FFF;"
77 | )
78 | ),
79 | right_text = 2018
80 | ),
81 | title = "test",
82 | body = bs4DashBody(
83 | bs4TabItems(
84 | bs4TabItem(
85 | tabName = "dashboard",
86 | tags$head(
87 | tags$link(
88 | rel = "stylesheet",
89 | type = "text/css",
90 | href = "styles.css"
91 | )
92 | ),
93 | useShinyjs(),
94 | # br(), br(), br(),
95 | fluidRow(
96 | column(
97 | width = 12,
98 | fluidRow(
99 | column(
100 | width = 12,
101 | # bouton choisir ligne ----------------------------------------------------
102 | column(
103 | width = 6,
104 | align = "center",
105 | fluidRow(
106 | # Bouton type jour --------------------------------------------------------
107 |
108 | )
109 | )
110 | )
111 | ),
112 | fluidRow(
113 | column(
114 | width = 9,
115 | # Carte des stations ------------------------------------------------------
116 | bs4Card(
117 | title = "Paris - Carte Metro",
118 | status = "primary",
119 | solidHeader = FALSE,
120 | collapsible = FALSE,
121 | elevation = 4,
122 | width = NULL,
123 | leafletOutput("carte", height = 450)
124 | )
125 | ),
126 | column(
127 | width = 3,
128 | # valueBox1 ----------------------------------------------------------------
129 | fluidRow(
130 | bs4ValueBoxOutput("bigger_station", width = 12)),
131 |
132 | # valueBox2 ----------------------------------------------------------------
133 | fluidRow(
134 | bs4ValueBoxOutput("n_validation", width = 12)),
135 |
136 | # valueBox3 ----------------------------------------------------------------
137 | fluidRow(
138 | bs4ValueBoxOutput("indic_validation", width = 12)),
139 |
140 | # valueBox4 ----------------------------------------------------------------
141 | fluidRow(
142 | bs4ValueBoxOutput("indic_validation2", width = 12))
143 | )
144 | ),
145 | fluidRow(
146 | # Box section info Lignes -------------------------------------------------
147 | bs4Card(
148 | collapsible = FALSE,
149 | solidHeader = TRUE,
150 | title = "Informations Lignes : Le saviez-vous ? ",
151 | status = "primary",
152 | width = 4,
153 | uiOutput(outputId = "info_ligne")
154 | ),
155 | # Box profil horaire ------------------------------------------------------------------
156 | bs4Card(
157 | collapsible = FALSE,
158 | solidHeader = TRUE,
159 | title = "Profil de frequentation horaire ",
160 | status = "primary",
161 | width = 8,
162 | prettyToggle(
163 | inputId = "type_valeur_horaire",
164 | label_on = "Nb",
165 | label_off = "%",
166 | value = TRUE,
167 | shape = "round",
168 | outline = TRUE,
169 | fill = TRUE
170 | ),
171 | fluidRow(
172 | column(
173 | width = 4,
174 | billboarderOutput(outputId = "graph_p_h_vacs", width = "100%")
175 | ),
176 | column(
177 | width = 4,
178 | billboarderOutput(outputId = "graph_p_h_we", width = "100%")
179 | ),
180 | column(
181 | width = 4,
182 | billboarderOutput(outputId = "graph_p_h_jouv", width = "100%")
183 | )
184 | )
185 | )
186 | )
187 | )
188 | )
189 | ),
190 | bs4TabItem(
191 | tabName = "about",
192 | br(), br(),
193 | fluidRow(
194 | column(
195 | width = 12,
196 | align = "center",
197 | bs4Card(
198 | title = "About",
199 | status = "primary",
200 | collapsible = FALSE,
201 | solidHeader = TRUE,
202 | width = 6,
203 | descriptif_application()
204 | )
205 | )
206 | )
207 | )
208 | )
209 | )
210 | )
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_10_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_11_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_12_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_13_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_14_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_1_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_2_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_3_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_3bis_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_4_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_5_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_6_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_7_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_7bis_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_8_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/Paris_m_9_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/logo_blanc_ratp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/www/logo_blanc_ratp.png
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/logo_dreamRs_couleur.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/www/logo_dreamRs_couleur.png
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/screenshot_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic-bs4Dash/www/screenshot_app.png
--------------------------------------------------------------------------------
/ratp-traffic-bs4Dash/www/styles.css:
--------------------------------------------------------------------------------
1 |
2 | /* Styles for metro map app */
3 |
4 | .map-container {
5 | position: fixed;
6 | top: 0;
7 | left: 0;
8 | right: 0;
9 | bottom: 0;
10 | overflow: hidden;
11 | padding: 0;
12 | }
13 |
14 | .controls-pane {
15 | border-radius: 5px;
16 | border: 1px solid #112446;
17 | background-color: #FFF;
18 | padding: 5px;
19 | }
20 |
21 |
22 | /* Custom styles */
23 |
24 | .dropdown-menu {
25 | z-index: 100000000000 !important;
26 | }
27 |
28 | h3 {
29 | white-space: nowrap;
30 | overflow: hidden;
31 | text-overflow: ellipsis;
32 | }
33 |
34 | .navbar-header {
35 | margin-left: 8.33% !important;
36 | }
37 |
38 | .bg-navy {
39 | background-color: #18bc9c !important;
40 | }
41 |
42 | .small-box .icon-large {
43 | color: #FFFFFF78 !important;
44 | }
45 |
46 | .box.box-primary {
47 | border-top-color: #18bc9c !important;
48 | }
49 |
50 | .box.box-solid.box-primary {
51 | border: 1px solid #18bc9c !important;
52 | }
53 |
54 | .box.box-solid.box-primary>.box-header {
55 | color: #fff;
56 | background: #18bc9c !important;
57 | background-color: #18bc9c !important;
58 | }
59 |
60 | .nav-tabs-custom>.nav-tabs>li.active {
61 | border-top-color: #18bc9c !important;
62 | }
63 |
64 | .box.box-solid.box-success>.box-header {
65 | color: #fff;
66 | background: #18bc9c !important;
67 | background-color: #18bc9c !important;
68 | }
69 |
70 |
71 | .checkbox-bs-success input[type="checkbox"]:checked + label::before, .checkbox-bs-success input[type="radio"]:checked + label::before {
72 | background-color: #18bc9c !important;
73 | border-color: #18bc9c !important;
74 | }
75 |
76 |
77 | .dreamrs {
78 | background-image:url(logo_dreamRs_couleur.png);
79 | background-repeat:no-repeat;
80 | background-position:right bottom;
81 | background-size: 156px 100px;
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/ratp-traffic/datas/NVALDTOT_STAT_CATJOUR_LIGNE.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/datas/NVALDTOT_STAT_CATJOUR_LIGNE.rds
--------------------------------------------------------------------------------
/ratp-traffic/datas/info_ligne.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/datas/info_ligne.rds
--------------------------------------------------------------------------------
/ratp-traffic/datas/lignes_metro.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/datas/lignes_metro.rds
--------------------------------------------------------------------------------
/ratp-traffic/datas/plan_metro.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/datas/plan_metro.rds
--------------------------------------------------------------------------------
/ratp-traffic/datas/profil_horaire_global.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/datas/profil_horaire_global.rds
--------------------------------------------------------------------------------
/ratp-traffic/datas/profil_horaire_ligne.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/datas/profil_horaire_ligne.rds
--------------------------------------------------------------------------------
/ratp-traffic/datas/validation_metro.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/datas/validation_metro.rds
--------------------------------------------------------------------------------
/ratp-traffic/funs/box_icon.R:
--------------------------------------------------------------------------------
1 |
2 | box_icon <- function(...) {
3 | tags$div(
4 | class="list-group",
5 | lapply(
6 | X = list(...),
7 | FUN = function(x) {
8 | tags$span(
9 | class="list-group-item",
10 | tags$span(icon(x$icon, class = "fa-fw fa-lg"), style = paste("color: ", x$col)),
11 | HTML(" "),
12 | x$text
13 | )
14 | }
15 | )
16 | )
17 | }
18 |
--------------------------------------------------------------------------------
/ratp-traffic/funs/descriptif_application.R:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | descriptif_application <- function() {
5 | tags$div(
6 | class = "dreamrs",
7 | tags$b("Info :"),
8 | tags$ul(
9 | tags$li("L\'application d\u00e9crit le traffic du m\u00e9tro parisien pour l\'ann\u00e9e 2017 par station, ligne et type de jour s\u00e9lectionn\u00e9.
10 | Elle d\u00e9crit aussi les caract\u00e9ristiques des diff\u00e9rentes lignes du m\u00e9tro parisien."),
11 | tags$li("Le nombre de validations calcul\u00e9 ne comptabilise que les entr\u00e9es sur le r\u00e9seau avec une carte d\'abonnement."),
12 | tags$li("Les validations avec un ticket ainsi que les validations de sortie ne sont donc pas prises en compte.")
13 | ),
14 | tags$b("Donn\u00e9es :"),
15 | tags$ul(
16 | tags$li(
17 | "L\' application a \u00e9t\u00e9 cr\u00e9\u00e9e \u00e0 partir des donn\u00e9es Open du STIF : ",
18 | tags$a("OpenData stif info",
19 | href = "https://opendata.stif.info/")
20 | ),
21 | tags$li("Les informations sur les lignes viennent de Wikipedia")
22 | ),
23 | tags$b("Packages :"),
24 | tags$ul(
25 | tags$li(tags$a("shiny", href = "https://shiny.rstudio.com/"), ": pour l\'application"),
26 | tags$li(tags$a("shinyWidgets", href = "https://github.com/dreamRs/shinyWidgets"), ", ",
27 | tags$a("shinythemes", href = "https://rstudio.github.io/shinythemes/"), ", et ",
28 | tags$a("shinydashboard", href = "https://rstudio.github.io/shinydashboard/"),
29 | ": pour customiser l\'apparence de l\'application"),
30 | tags$li(tags$a("leaflet", href = "https://rstudio.github.io/leaflet/"),
31 | ": pour cr\u00e9er la carte"),
32 | tags$li(tags$a("leaflet.extras", href = "https://github.com/bhaskarvk/leaflet.extras"),
33 | ": pour rechercher un endroit sur la carte"),
34 | tags$li(tags$a("dplyr", href = "https://github.com/tidyverse/dplyr"),
35 | ": pour manipuler les donn\u00e9es"),
36 | tags$li(tags$a("billboarder", href = "https://github.com/dreamRs/billboarder"),
37 | ": pour les graphiques du profil de fr\u00e9quentation horaire"),
38 | tags$li(tags$a("stringr", href = "https://github.com/tidyverse/stringr"),
39 | ": pour les cha\u00eenes de caract\u00e8res"),
40 | tags$li(tags$a("scales", href = "https://github.com/r-lib/scales"),
41 | ": pour normaliser le vecteur Nombre de validation afin d\'ajuster la taille des points (stations) sur la carte")
42 | ),
43 | tags$b("Auteur :"), # tags$b : titre
44 | tags$div("Cette application a \u00e9t\u00e9 d\u00e9velopp\u00e9e par Philippine Rheins ",
45 | tags$a(class = "btn btn-default", icon("twitter"), "@Philippine",
46 | href = "https://twitter.com/PhilippineRs", style = "background-color: #1DA1F2; color: #FFF;"
47 | )),
48 | tags$div("Pour en voir d\'autres, n\'h\u00e9sitez pas \u00e0 visiter notre site : ",
49 | tags$a("dreamrs.fr", href = "https://www.dreamrs.fr/")),
50 | tags$div(
51 | "ou \u00e0 nous suivre sur Twitter : ",
52 | tags$a(
53 | class = "btn btn-default", icon("twitter"), "@dreamRs",
54 | href = "https://twitter.com/dreamRs_fr", style = "background-color: #1DA1F2; color: #FFF;"
55 | )
56 | )
57 | )
58 | }
59 |
--------------------------------------------------------------------------------
/ratp-traffic/funs/graph_profil_horaire.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | #' Graphique pour representer les profils horaires de validation
4 | #'
5 | #' @param data un \code{data.frame} avec les donnees de validation
6 | #' @param jour Jour considere
7 | #' @param title Titre du graphique
8 | #' @param ylab Titre de l'axe des abscisses
9 | #' @param col Couleur des barres
10 | #'
11 | #'
12 | #' @examples
13 | #'
14 | #' library(dplyr)
15 | #' library(highcharter)
16 | #'
17 | #' profil_horaire_ligne <- readRDS("Datas/profil_horaire_ligne.rds")
18 | #' phl1 <- profil_horaire_ligne %>%
19 | #' filter(LIGNE == "1") %>%
20 | #' rename(VALD = NB_VALD)
21 | #'
22 | #'
23 | #'
24 | #' graph_profil_hor(data = phl1)
25 | #'
26 | #' graph_profil_hor(data = phl1, jour = "vacances", title = "Vacances")
27 | #' graph_profil_hor(data = phl1, jour = "weekend", title = "Week-end")
28 | #'
29 | graph_profil_hor <- function(data,
30 | jour = "vacances",
31 | title = "Vacances",
32 | ylab = "Nbre de validation",
33 | col = "#18bc9c",
34 | percent = FALSE) {
35 |
36 | max_yaxis <- max(data$VALD)
37 | breaks_yaxis <- scales::pretty_breaks()(c(0, max_yaxis))[-1]
38 |
39 | if (percent) {
40 | format_y_axis <- suffix("%")
41 | tooltip_format <- "d[0].value + '%'"
42 | } else {
43 | format_y_axis <- htmlwidgets::JS("function(x) {return d3.format('.2s')(x);}")
44 | tooltip_format <- "d3.format('\u00a0>7,')(d[0].value)"
45 | }
46 |
47 | data <- data %>%
48 | filter(type_jour == jour) %>%
49 | mutate(COLOR = col) %>%
50 | mutate(TRNC_HORR = stringr::str_remove(TRNC_HORR, "-\\d{1,2}h"))
51 |
52 | billboarder(data = data) %>%
53 | bb_barchart(mapping = bbaes(x = TRNC_HORR, y = VALD), color = col) %>%
54 | bb_y_grid(show = TRUE) %>%
55 | bb_grid(front = TRUE) %>%
56 | bb_x_axis(tick = list(multiline = FALSE)) %>%
57 | bb_y_axis(
58 | show = jour == "vacances",
59 | inner = TRUE,
60 | max = max_yaxis,
61 | tick = list(
62 | text = list(
63 | position = list(x = 0, y = 10)
64 | ),
65 | format = format_y_axis,
66 | values = breaks_yaxis
67 | ),
68 | label = list(text = ylab, position = "outer-top")
69 | ) %>%
70 | bb_tooltip(
71 | linked = list(name = "tooltip-profil-horaire"),
72 | contents = htmlwidgets::JS(
73 | paste0(
74 | "function(d, defaultTitleFormat, defaultValueFormat, color) {
75 | var lib = ['0h - 2h','2h- 4h','4h - 6h','6h - 8h','8h - 10h','10h - 12h','12h - 14h','14h - 16h','16h - 18h','18h - 20h','20h - 22h','22h - 0h'];
76 | //console.log(d);
77 | d3.formatDefaultLocale({'decimal': ',',
78 | 'thousands': '\u00a0',
79 | 'grouping': [3],
80 | 'currency': ['', '\u00a0€'],
81 | 'percent': '\u202f%'});
82 |
83 | return lib[d[0].index] + ': ' + ", tooltip_format, " + '';}"
84 | )
85 | ),
86 | position = htmlwidgets::JS(
87 | "function(data, width, height, element) {console.log(element) ; return {top: 0, right: 100};}"
88 | )
89 | ) %>%
90 | bb_legend(show = FALSE) %>%
91 | bb_labs(title = title) %>%
92 | bb_add_style(".bb-tooltip-container" = "right: 10px; border: 1px solid #18bc9c; border-radius: 5px; padding: 4px;")
93 | }
94 |
--------------------------------------------------------------------------------
/ratp-traffic/funs/import_validation.R:
--------------------------------------------------------------------------------
1 |
2 | #' Import des données de validation du STIF
3 | #'
4 | #' @param file chemin du fichier csv à importer.
5 | #' @param format_jour format a appliquer sur la date par défaut le numéro et le jour de la semaine.
6 | #'
7 | #' @return renvoie un data.frame
8 | #' @export
9 | #'
10 | #' @examples
11 | #' mydata <- import_validation("chemin/fichier.csv")
12 |
13 | import_validation <- function(file, format_jour = "%u-%A") {
14 | if (!file.exists(file)) {
15 | stop("Ce fichier n'existe pas ! ")
16 | }
17 | if (!require("dplyr")) {
18 | stop("dplyr doit etre installe")
19 | }
20 | data <- read.table(file = file,
21 | sep = ";",
22 | header = TRUE,
23 | colClasses = "character",
24 | quote = "",
25 | stringsAsFactors = FALSE,
26 | encoding = 'UTF-8')
27 | data <- data %>%
28 | mutate(JOUR = as.Date(JOUR),
29 | JOUR_SEMAINE = format(JOUR, format = format_jour)) %>%
30 | mutate(NB_VALD = gsub(pattern = "[^0-9]", replacement = "", x = NB_VALD),
31 | NB_VALD = as.numeric(NB_VALD)) %>%
32 | arrange(JOUR)
33 | return(data)
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/ratp-traffic/global.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : RATP validations - Global
5 | # By : Philippine
6 | # Date : 2018-08-07
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 |
12 |
13 | # Packages ----------------------------------------------------------------
14 |
15 | library(dplyr)
16 | library(shiny)
17 | library(shinydashboard)
18 | library(shinythemes)
19 | library(shinyWidgets)
20 | library(leaflet)
21 | library(leaflet.extras)
22 | library(stringr)
23 | library(scales)
24 | library(billboarder)
25 | library(sf)
26 |
27 |
28 | # funs --------------------------------------------------------------------
29 |
30 | source("funs/box_icon.R")
31 | source("funs/graph_profil_horaire.R")
32 | source("funs/descriptif_application.R")
33 |
34 |
35 |
36 | # datas -------------------------------------------------------------------
37 |
38 | lignes_metro <- readRDS("datas/lignes_metro.rds")
39 | info_ligne <- readRDS("datas/info_ligne.rds")
40 | NVALDTOT_STAT_CATJOUR_LIGNE <- readRDS("datas/NVALDTOT_STAT_CATJOUR_LIGNE.rds")
41 | validation <- readRDS("datas/validation_metro.rds")
42 | profil_horaire_ligne <- readRDS("datas/profil_horaire_ligne.rds")
43 | profil_horaire_global <- readRDS("datas/profil_horaire_global.rds")
44 | plan_metro <- readRDS("datas/plan_metro.rds")
45 | metrolines <- c("1","2","3","3bis","4","5","6","7","7bis","8","9","10","11","12","13","14")
46 | validation_ligne <- inner_join(
47 | x = lignes_metro %>% select(-NOM_ARRET),
48 | y = validation,
49 | by = "ID_ARRET"
50 | )
51 |
52 | couleur_ligne <- data.frame(
53 | LIGNE = c("1", "2", "3", "3b", "4", "5", "6", "7", "7b", "8", "9", "10", "11", "12", "13", "14"),
54 | code_hexa = c("#FFCD00","#003CA6","#837902","#6EC4E8","#CF009E","#FF7E2E","#6ECA97","#FA9ABA",
55 | "#6ECA97","#E19BDF","#B6BD00","#C9910D","#704B1C","#007852","#6EC4E8","#62259D"),
56 | stringsAsFactors = FALSE
57 | )
58 | couleur_ligne$LIGNE <- ordered(x = couleur_ligne$LIGNE, couleur_ligne$LIGNE)
59 |
60 | pal <- colorFactor(
61 | levels = levels(couleur_ligne$LIGNE),
62 | palette = couleur_ligne$code_hexa
63 | )
64 |
65 |
--------------------------------------------------------------------------------
/ratp-traffic/server.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : RATP validations - Server
5 | # By : Philippine
6 | # Date : 2018-08-07
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 |
12 | function(input, output) {
13 |
14 | type_jour_r <- reactiveValues(x = c("Jour ouvre", "weekend", "vacances"))
15 | observeEvent(input$type_jour, {
16 | if (is.null(input$type_jour)) {
17 | type_jour_r$x <- c("Jour ouvre", "weekend", "vacances")
18 | } else {
19 | type_jour_r$x <- input$type_jour
20 | }
21 | }, ignoreNULL = FALSE)
22 |
23 |
24 | # reactive fct for n_validation value_box ------------------------------------------------------------------
25 |
26 | nvald_lign_catj <- reactive({
27 | ss_tbl <- NVALDTOT_STAT_CATJOUR_LIGNE %>%
28 | filter(LIGNE == input$choix_ligne & CAT_JOUR2 %in% type_jour_r$x) %>%
29 | select(NB_VALD_STAT_CATJ_2017)
30 | return(ss_tbl)
31 | })
32 |
33 |
34 |
35 | # reactive fct for indic_validation value_box nvald_lign_jour_catj pour value_box ------------------------------------------------------------------
36 | nvald_lign_jour_catj <- reactive({
37 | vald_ligne <- validation_ligne %>%
38 | filter(LIGNE == input$choix_ligne & CAT_JOUR2 %in% type_jour_r$x) %>%
39 | select(NB_VALD)
40 | return(vald_ligne)
41 | })
42 |
43 |
44 |
45 |
46 | # valueBox 1 - bigger_station -------------------------------------------------
47 |
48 | output$bigger_station<- renderValueBox({
49 | req(input$choix_ligne)
50 | if(input$choix_ligne == "ALL"){
51 | titre <- NVALDTOT_STAT_CATJOUR_LIGNE %>%
52 | filter(CAT_JOUR2 %in% type_jour_r$x)
53 | } else {
54 | titre <- NVALDTOT_STAT_CATJOUR_LIGNE %>%
55 | filter(LIGNE == input$choix_ligne & CAT_JOUR2 %in% type_jour_r$x)
56 | }
57 | titre %>%
58 | filter(NB_VALD_STAT_CATJ_2017 == max(NB_VALD_STAT_CATJ_2017)) %>%
59 | pull(NOM_ARRET) %>%
60 | str_to_title %>%
61 | valueBox(
62 | subtitle = "station la plus fr\u00e9quent\u00e9e",
63 | icon = icon("map-marker"),
64 | color = "navy"
65 | )
66 | })
67 |
68 |
69 |
70 |
71 | # valueBox2 - n_validation -------------------------------------------------
72 |
73 | output$n_validation <- renderValueBox({
74 | nvald_lign_jour <- nvald_lign_catj()
75 | if(input$choix_ligne == "ALL"){
76 | titre <- format(sum(validation$NB_VALD[validation$CAT_JOUR2 %in% type_jour_r$x]),
77 | big.mark = " ",
78 | scientific = FALSE)
79 | } else {
80 | titre <- format(sum(nvald_lign_jour),
81 | big.mark = " ",
82 | scientific = FALSE)
83 | }
84 | valueBox(
85 | value = titre,
86 | subtitle = " validations",
87 | icon = icon("ticket"),
88 | color = "navy",
89 | width = 3
90 | )
91 | })
92 |
93 | # valueBox3 - indic_validation ---------------------------------------------
94 |
95 | output$indic_validation <- renderValueBox({
96 | vald_ligne <- nvald_lign_jour_catj()
97 | if(input$choix_ligne == "ALL"){
98 | titre <- format(round(mean(validation$NB_VALD[validation$CAT_JOUR2 %in% type_jour_r$x]), 0),
99 | big.mark = " ",
100 | scientific = FALSE)
101 | } else {
102 | titre <- format(round(mean(vald_ligne$NB_VALD), 0),
103 | big.mark = " ",
104 | scientific = FALSE)
105 | }
106 | valueBox(
107 | value = titre,
108 | subtitle = " validations en moyenne /jour sur une station",
109 | icon = icon("sun-o"),
110 | color = "navy",
111 | width = 3
112 | )
113 | })
114 | # valueBox4 - indic_validation ---------------------------------------------
115 |
116 | output$indic_validation2 <- renderValueBox({
117 | vald_ligne <- nvald_lign_jour_catj()
118 | if(input$choix_ligne == "ALL"){
119 | titre <- format(round(mean(validation$NB_VALD[validation$CAT_JOUR2 %in% type_jour_r$x])/1440,0),
120 | big.mark = " ",
121 | scientific = FALSE)
122 | } else {
123 | titre <- format(round(mean(vald_ligne$NB_VALD)/1440,0),
124 | big.mark = " ",
125 | scientific = FALSE)
126 | }
127 | titre %>%
128 | valueBox(
129 | subtitle = " validations en moyenne /min sur une station : ",
130 | icon = icon("clock-o"),
131 | color = "navy",
132 | width = 3)
133 | })
134 |
135 |
136 |
137 | # carte leaflet -----------------------------------------------------------
138 | output$carte <- renderLeaflet({
139 | if(input$choix_ligne == "ALL") {
140 | NVALDTOT_STAT_CATJOUR_LIGNE %>%
141 | filter(CAT_JOUR2 %in% type_jour_r$x) %>%
142 | group_by(ID_ARRET, NOM_ARRET, LIGNE, stop_lat, stop_lon, Code_hexa) %>%
143 | summarise(NB_VALD_STAT_CATJ_2017 = sum(NB_VALD_STAT_CATJ_2017)) %>%
144 | as.data.frame() %>%
145 | ungroup() %>%
146 | mutate(rad = rescale(NB_VALD_STAT_CATJ_2017, to = c(2, 20))) %>%
147 | arrange(stop_lon, stop_lat) %>%
148 | leaflet(options = leafletOptions(zoomControl = FALSE)) %>%
149 | addProviderTiles("CartoDB", group = "Carto") %>%
150 | addTiles(group = "OSM") %>%
151 | addProviderTiles("Esri", group = "Esri") %>%
152 | setView(lng = 2.352222, lat = 48.8566, zoom = 12) %>%
153 | addCircleMarkers( lng = ~stop_lon,
154 | lat = ~stop_lat,
155 | popup = ~paste0(NOM_ARRET, "
", "", "Nombre de validation : ",
156 | format(NB_VALD_STAT_CATJ_2017, big.mark = " ", scientific = FALSE),
157 | "", "
",
158 | "Ligne ", LIGNE),
159 | radius = ~rad,
160 | color = ~pal(LIGNE),
161 | stroke = TRUE,
162 | opacity = 1,
163 | fillColor = ~pal(LIGNE),
164 | fillOpacity = 1) %>%
165 | addPolylines(data = plan_metro,
166 | color = ~hexcolor,
167 | weight = 2,
168 | opacity = 1) %>%
169 | addSearchOSM(options = searchFeaturesOptions(position = 'topright')) %>%
170 | addResetMapButton() %>%
171 | addLayersControl(baseGroups = c("Carto","OSM", "Esri"))
172 | } else {
173 | NVALDTOT_STAT_CATJOUR_LIGNE %>%
174 | filter(LIGNE == input$choix_ligne &
175 | CAT_JOUR2 %in% type_jour_r$x) %>%
176 | group_by(ID_ARRET, NOM_ARRET, LIGNE, stop_lat, stop_lon, Code_hexa) %>%
177 | summarise(NB_VALD_STAT_CATJ_2017 = sum(NB_VALD_STAT_CATJ_2017)) %>%
178 | as.data.frame() %>%
179 | ungroup() %>%
180 | mutate(rad = rescale(NB_VALD_STAT_CATJ_2017, to = c(2, 20))) %>%
181 | arrange(stop_lon, stop_lat) %>%
182 | leaflet(options = leafletOptions(zoomControl = FALSE)) %>%
183 | addProviderTiles("CartoDB", group = "Carto") %>%
184 | setView(lng = 2.352222, lat = 48.8566, zoom = 12) %>%
185 | addCircleMarkers( lng = ~stop_lon,
186 | lat = ~stop_lat,
187 | popup = ~paste0(NOM_ARRET, "
", "", "Nombre de validation : ",
188 | format(NB_VALD_STAT_CATJ_2017, big.mark = " ", scientific = FALSE), "", "
",
189 | "Ligne ", LIGNE),
190 | radius = ~rad,
191 | stroke = TRUE,
192 | opacity = 1,
193 | color = ~pal(LIGNE),
194 | fillColor = ~pal(LIGNE),
195 | fillOpacity = 1) %>%
196 | addPolylines(data = plan_metro %>% filter(indice_lig == input$choix_ligne),
197 | color = ~hexcolor,
198 | weight = 2,
199 | opacity = 1) %>%
200 | addSearchOSM(options = searchFeaturesOptions(position = 'topright')) %>%
201 | addResetMapButton() %>%
202 | addLayersControl(baseGroups = c("Carto","OSM", "Esri"))
203 | }
204 | })
205 |
206 |
207 | # couleur graphique reactive et icone de section infoligne -------------------------
208 | colligne <- reactive({
209 | if (input$choix_ligne == "ALL"){
210 | col <- "#18bc9c"
211 | } else {
212 | col <- couleur_ligne$code_hexa[couleur_ligne$LIGNE == input$choix_ligne]
213 | }
214 | return(col)
215 | })
216 |
217 |
218 | # section info ligne ------------------------------------------------------
219 | output$info_ligne <- renderUI({
220 | if(input$choix_ligne == "ALL"){
221 | tags$div(
222 | box_icon(
223 | list(icon = "calendar-o", col = colligne(),
224 | text = paste("Ouverture de la premi\u00e8re ligne en ", info_ligne$annee_ouv[info_ligne$LIGNE == input$choix_ligne])
225 | ),
226 | list(icon = "code-fork", col = colligne(),
227 | text = paste("16 lignes")
228 | ),
229 | list(icon = "map-marker", col = colligne(),
230 | text = paste(info_ligne$n_station[info_ligne$LIGNE == input$choix_ligne], " stations")
231 | ),
232 | list(icon = "clock-o", col = colligne(),
233 | text = paste("Temps de parcours moyen d\'une ligne : ", info_ligne$tps_parcours[info_ligne$LIGNE == input$choix_ligne], "minutes" )
234 | ),
235 | list(icon = "long-arrow-right", col = colligne(),
236 | text = paste(info_ligne$longueur[info_ligne$LIGNE == input$choix_ligne], "km de longueur")
237 | ),
238 | list(icon = "arrows-h", col = colligne(),
239 | text = paste("Distance moyenne entre 2 stations : ", info_ligne$dist_moy_arret[info_ligne$LIGNE == input$choix_ligne], "m\u00e8tres" )
240 | ),
241 | list(icon = "male", col = colligne(),
242 | text = paste("Temps de marche moyen entre 2 arr\u00eats : ", info_ligne$tps_marche_2_arret[info_ligne$LIGNE == input$choix_ligne], " minutes")
243 | ),
244 | list(icon = "subway", col = colligne(),
245 | text = paste("M\u00e9tro automatique : ", info_ligne$auto[info_ligne$LIGNE == input$choix_ligne])
246 | ),
247 | list(icon = "subway", col = colligne(),
248 | text = paste(info_ligne$nb_rames[info_ligne$LIGNE == input$choix_ligne], "rames de m\u00e9tro")
249 | ),
250 | list(icon = "home", col = colligne(),
251 | text = paste(info_ligne$nb_commune_desservi[info_ligne$LIGNE == input$choix_ligne], "communes desservies")
252 | ),
253 | list(icon = "hand-pointer-o", col = colligne(),
254 | text = paste("Arrondissement majoritairement desservi : ", info_ligne$arrdsmt_pcpal[info_ligne$LIGNE == input$choix_ligne])
255 | )
256 | )
257 | )
258 | } else {
259 | tags$div(
260 | box_icon(
261 | list(icon = "map-marker", col = colligne(),
262 | text = paste(info_ligne$n_station[info_ligne$LIGNE == input$choix_ligne], " stations")
263 | ),
264 | list(icon = "subway", col = colligne(),
265 | text = paste("M\u00e9tro automatique : ", info_ligne$auto[info_ligne$LIGNE == input$choix_ligne])
266 | ),
267 | list(icon = "calendar-o", col = colligne(),
268 | text = paste("Ouverture de la ligne en ", info_ligne$annee_ouv[info_ligne$LIGNE == input$choix_ligne])
269 | ),
270 | list(icon = "clock-o", col = colligne(),
271 | text = paste("Ligne parcouru en ", info_ligne$tps_parcours[info_ligne$LIGNE == input$choix_ligne], "minutes" )
272 | ),
273 | list(icon = "arrows-h", col = colligne(),
274 | text = paste("Distance moyenne entre 2 stations : ", info_ligne$dist_moy_arret[info_ligne$LIGNE == input$choix_ligne], "m\u00e8tres" )
275 | ),
276 | list(icon = "long-arrow-right", col = colligne(),
277 | text = paste(info_ligne$longueur[info_ligne$LIGNE == input$choix_ligne], "km de longueur")
278 | ),
279 | list(icon = "arrows-alt", col = colligne(),
280 | text = paste(info_ligne$n_corresp[info_ligne$LIGNE == input$choix_ligne], "correspondances sur la ligne")
281 | ),
282 | list(icon = "subway", col = colligne(),
283 | text = paste(info_ligne$nb_rames[info_ligne$LIGNE == input$choix_ligne], "rames de m\u00e9tro")
284 | ),
285 | list(icon = "male", col = colligne(),
286 | text = paste(info_ligne$tps_marche_2_arret[info_ligne$LIGNE == input$choix_ligne], " minutes de temps de marche moyen entre 2 arr\u00eats")
287 | ),
288 | list(icon = "home", col = colligne(),
289 | text = paste(info_ligne$nb_commune_desservi[info_ligne$LIGNE == input$choix_ligne], "communes desservies")
290 | ),
291 | list(icon = "hand-pointer-o", col = colligne(),
292 | text = paste("Arrondissement(s) majoritairement desservi : ", info_ligne$arrdsmt_pcpal[info_ligne$LIGNE == input$choix_ligne])
293 | )
294 | )
295 | )
296 | }
297 | })
298 |
299 |
300 |
301 | # fonction reactive pour graph profil horaire ---------------------------
302 |
303 | ss_tbl_profil_hor <- reactive({
304 | if(input$choix_ligne == "ALL"){ # ALL
305 |
306 |
307 | if(input$type_valeur_horaire == TRUE){ # ALL NB
308 | ss_tbl <- profil_horaire_global %>%
309 | select(TRNC_HORR, type_jour, NB_VALD) %>%
310 | rename(VALD = NB_VALD)
311 | return(ss_tbl)
312 | } else { # ALL PCT
313 | ss_tbl <- profil_horaire_global %>%
314 | select(TRNC_HORR, type_jour, PCT_VALD) %>%
315 | rename(VALD = PCT_VALD)
316 | return(ss_tbl)
317 | }
318 |
319 |
320 | } else { # LIGNE
321 |
322 |
323 | if(input$type_valeur_horaire == TRUE){ # LIGNE NB
324 | ss_tbl <- profil_horaire_ligne %>%
325 | ungroup() %>%
326 | filter(LIGNE == input$choix_ligne) %>%
327 | select(TRNC_HORR, type_jour, NB_VALD) %>%
328 | rename(VALD = NB_VALD)
329 | return(ss_tbl)
330 |
331 | } else { # LIGNE PCT
332 | ss_tbl <- profil_horaire_ligne %>%
333 | ungroup() %>%
334 | filter(LIGNE == input$choix_ligne) %>%
335 | select(TRNC_HORR, type_jour, PCT_VALD) %>%
336 | rename(VALD = PCT_VALD)
337 | return(ss_tbl)
338 | }
339 |
340 | }
341 |
342 |
343 | })
344 |
345 | # Graphique profil horaire ---------------------------------------------
346 |
347 | # 1. Graphique des vacances -----------------------------------------------
348 |
349 | output$graph_p_h_vacs <- renderBillboarder({
350 | if(isTRUE(input$type_valeur_horaire)){
351 | graph_profil_hor(data = ss_tbl_profil_hor(),
352 | jour = "vacances",
353 | title = "Vacances",
354 | ylab = 'validations moyenne par heure',
355 | col = colligne(),
356 | percent = !isTRUE(input$type_valeur_horaire))
357 | } else {
358 | graph_profil_hor(data = ss_tbl_profil_hor(),
359 | jour = "vacances",
360 | title = "Vacances",
361 | ylab = '% de validation par heure',
362 | col = colligne(),
363 | percent = !isTRUE(input$type_valeur_horaire))
364 | }
365 | })
366 |
367 |
368 | # 2. Graphique du weekend -------------------------------------------------
369 |
370 | output$graph_p_h_we <- renderBillboarder({
371 | graph_profil_hor(data = ss_tbl_profil_hor(),
372 | jour = "weekend",
373 | title = "Weekend",
374 | col = colligne(),
375 | percent = !isTRUE(input$type_valeur_horaire))
376 | })
377 |
378 |
379 | # 3. Graphique des Jours ouvres -------------------------------------------
380 |
381 | output$graph_p_h_jouv <- renderBillboarder({
382 | graph_profil_hor(data = ss_tbl_profil_hor(),
383 | jour = "Jour ouvre",
384 | title = "Jour ouvr\u00e9s",
385 | col = colligne(),
386 | percent = !isTRUE(input$type_valeur_horaire))
387 | })
388 |
389 |
390 | } # end script
--------------------------------------------------------------------------------
/ratp-traffic/ui.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : RATP validations - UI
5 | # By : Philippine
6 | # Date : 2018-08-07
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 | library("shiny")
12 |
13 | navbarPage(
14 | title = "Le M\u00e9tro parisien en 2017",
15 | header = tagList(
16 | useShinydashboard(),
17 | setBackgroundColor(color = c("ghostwhite")),
18 | tags$link(rel="stylesheet", type="text/css", href="styles.css")
19 | ),
20 | inverse = TRUE,
21 | theme = shinythemes::shinytheme(theme = "flatly"),
22 |
23 | tabPanel(
24 | title = "Tableau de bord",
25 |
26 | fluidRow(
27 | column(
28 | width = 10, offset = 1,
29 |
30 |
31 | fluidRow(
32 | column(
33 | width = 12,
34 |
35 | # bouton choisir ligne ----------------------------------------------------
36 | div(style="display:inline-block",
37 | pickerInput(
38 | inputId = "choix_ligne",
39 | width = NULL, options = list(style = "btn-success"),
40 | multiple = FALSE,
41 | choices = c("ALL",levels(lignes_metro$LIGNE)),
42 | choicesOpt = list(
43 | content = c(
44 | sprintf("
- Choisissez une ligne : "),
45 | sprintf("
Ligne %s",
46 | metrolines, metrolines)
47 | )
48 | ),
49 | selected = "Choisissez une ligne"
50 | )
51 | ),
52 |
53 | # Bouton type jour --------------------------------------------------------
54 | div(style="display:inline-block",
55 | awesomeCheckboxGroup(
56 | inputId = "type_jour",
57 | label = NULL,
58 | width = NULL,
59 | status = "success",
60 | choices = list("Vacances" = "vacances", "Week-end" = "weekend", "Jour ouvr\u00e9" = "Jour ouvre"),
61 | selected = c("Jour ouvre", "weekend", "vacances"),
62 | inline = TRUE
63 | )
64 | )
65 | )),
66 |
67 | fluidRow(
68 | column( width = 9,
69 |
70 | # Carte des stations ------------------------------------------------------
71 | box(title = "Paris - Carte Metro",
72 | status = "primary",
73 | solidHeader = TRUE,
74 | width = NULL,
75 | leafletOutput("carte", height = 410))
76 | ),
77 |
78 | column( width = 3,
79 |
80 | # valueBox1 ----------------------------------------------------------------
81 | fluidRow(
82 | valueBoxOutput("bigger_station", width = 12)),
83 |
84 | # valueBox2 ----------------------------------------------------------------
85 | fluidRow(
86 | valueBoxOutput("n_validation", width = 12)),
87 |
88 | # valueBox3 ----------------------------------------------------------------
89 | fluidRow(
90 | valueBoxOutput("indic_validation", width = 12)),
91 |
92 | # valueBox4 ----------------------------------------------------------------
93 | fluidRow(
94 | valueBoxOutput("indic_validation2", width = 12))
95 | )),
96 |
97 | fluidRow(
98 | # Box section info Lignes -------------------------------------------------
99 | box( title = "Informations Lignes : Le saviez-vous ? ",
100 | status = "primary",
101 | width = 4,
102 | uiOutput(outputId = "info_ligne")
103 | ),
104 |
105 | # Box profil horaire ------------------------------------------------------------------
106 | box(title = "Profil de frequentation horaire ",
107 | status = "primary",
108 | width = 8,
109 | prettyToggle(
110 | inputId = "type_valeur_horaire",
111 | label_on = "Nb",
112 | label_off = "%",
113 | value = TRUE,
114 | shape = "round",
115 | outline = TRUE,
116 | fill = TRUE
117 | ),
118 |
119 | fluidRow(
120 |
121 | column(
122 | width = 4,
123 | billboarderOutput(outputId = "graph_p_h_vacs", width = "100%")
124 | ),
125 |
126 | column(
127 | width = 4,
128 | billboarderOutput(outputId = "graph_p_h_we", width = "100%")
129 | ),
130 |
131 | column(
132 | width = 4,
133 | billboarderOutput(outputId = "graph_p_h_jouv", width = "100%")
134 | )
135 |
136 | )
137 | )
138 | )
139 |
140 | )
141 | )
142 | ),
143 | # A propos de l'application -----------------------------------------------
144 | tabPanel(
145 | title = "A propos de l\'application",
146 | fluidRow(
147 | column(
148 | width = 8, offset = 2,
149 | box(
150 | title = NULL, status = "primary", width = NULL,
151 | descriptif_application()
152 | )
153 | )
154 |
155 | )
156 | )
157 |
158 | )
159 |
160 |
161 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_10_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_11_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_12_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_13_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_14_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_1_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_2_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_3_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_3bis_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_4_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_5_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_6_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_7_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_7bis_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_8_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/Paris_m_9_jms.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/ratp-traffic/www/logo_blanc_ratp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/www/logo_blanc_ratp.png
--------------------------------------------------------------------------------
/ratp-traffic/www/logo_dreamRs_couleur.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/www/logo_dreamRs_couleur.png
--------------------------------------------------------------------------------
/ratp-traffic/www/screenshot_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/ratp-traffic/www/screenshot_app.png
--------------------------------------------------------------------------------
/ratp-traffic/www/styles.css:
--------------------------------------------------------------------------------
1 |
2 | /* Styles for metro map app */
3 |
4 | .map-container {
5 | position: fixed;
6 | top: 0;
7 | left: 0;
8 | right: 0;
9 | bottom: 0;
10 | overflow: hidden;
11 | padding: 0;
12 | }
13 |
14 | .controls-pane {
15 | border-radius: 5px;
16 | border: 1px solid #112446;
17 | background-color: #FFF;
18 | padding: 5px;
19 | }
20 |
21 |
22 | /* Custom styles */
23 |
24 | .dropdown-menu {
25 | z-index: 100000000000 !important;
26 | }
27 |
28 | h3 {
29 | white-space: nowrap;
30 | overflow: hidden;
31 | text-overflow: ellipsis;
32 | }
33 |
34 | .navbar-header {
35 | margin-left: 8.33% !important;
36 | }
37 |
38 | .bg-navy {
39 | background-color: #18bc9c !important;
40 | }
41 |
42 | .small-box .icon-large {
43 | color: #FFFFFF78 !important;
44 | }
45 |
46 | .box.box-primary {
47 | border-top-color: #18bc9c !important;
48 | }
49 |
50 | .box.box-solid.box-primary {
51 | border: 1px solid #18bc9c !important;
52 | }
53 |
54 | .box.box-solid.box-primary>.box-header {
55 | color: #fff;
56 | background: #18bc9c !important;
57 | background-color: #18bc9c !important;
58 | }
59 |
60 | .nav-tabs-custom>.nav-tabs>li.active {
61 | border-top-color: #18bc9c !important;
62 | }
63 |
64 | .box.box-solid.box-success>.box-header {
65 | color: #fff;
66 | background: #18bc9c !important;
67 | background-color: #18bc9c !important;
68 | }
69 |
70 |
71 | .checkbox-bs-success input[type="checkbox"]:checked + label::before, .checkbox-bs-success input[type="radio"]:checked + label::before {
72 | background-color: #18bc9c !important;
73 | border-color: #18bc9c !important;
74 | }
75 |
76 |
77 | .dreamrs {
78 | background-image:url(logo_dreamRs_couleur.png);
79 | background-repeat:no-repeat;
80 | background-position:right bottom;
81 | background-size: 156px 100px;
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/rentree_scolaire/LICENSE:
--------------------------------------------------------------------------------
1 | YEAR: 2017
2 | COPYRIGHT HOLDER: dreamRs
3 |
4 |
5 | GNU LESSER GENERAL PUBLIC LICENSE
6 | Version 3, 29 June 2007
7 |
8 | Copyright (C) 2007 Free Software Foundation, Inc.
9 | Everyone is permitted to copy and distribute verbatim copies
10 | of this license document, but changing it is not allowed.
11 |
12 |
13 | This version of the GNU Lesser General Public License incorporates
14 | the terms and conditions of version 3 of the GNU General Public
15 | License, supplemented by the additional permissions listed below.
16 |
17 | 0. Additional Definitions.
18 |
19 | As used herein, "this License" refers to version 3 of the GNU Lesser
20 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
21 | General Public License.
22 |
23 | "The Library" refers to a covered work governed by this License,
24 | other than an Application or a Combined Work as defined below.
25 |
26 | An "Application" is any work that makes use of an interface provided
27 | by the Library, but which is not otherwise based on the Library.
28 | Defining a subclass of a class defined by the Library is deemed a mode
29 | of using an interface provided by the Library.
30 |
31 | A "Combined Work" is a work produced by combining or linking an
32 | Application with the Library. The particular version of the Library
33 | with which the Combined Work was made is also called the "Linked
34 | Version".
35 |
36 | The "Minimal Corresponding Source" for a Combined Work means the
37 | Corresponding Source for the Combined Work, excluding any source code
38 | for portions of the Combined Work that, considered in isolation, are
39 | based on the Application, and not on the Linked Version.
40 |
41 | The "Corresponding Application Code" for a Combined Work means the
42 | object code and/or source code for the Application, including any data
43 | and utility programs needed for reproducing the Combined Work from the
44 | Application, but excluding the System Libraries of the Combined Work.
45 |
46 | 1. Exception to Section 3 of the GNU GPL.
47 |
48 | You may convey a covered work under sections 3 and 4 of this License
49 | without being bound by section 3 of the GNU GPL.
50 |
51 | 2. Conveying Modified Versions.
52 |
53 | If you modify a copy of the Library, and, in your modifications, a
54 | facility refers to a function or data to be supplied by an Application
55 | that uses the facility (other than as an argument passed when the
56 | facility is invoked), then you may convey a copy of the modified
57 | version:
58 |
59 | a) under this License, provided that you make a good faith effort to
60 | ensure that, in the event an Application does not supply the
61 | function or data, the facility still operates, and performs
62 | whatever part of its purpose remains meaningful, or
63 |
64 | b) under the GNU GPL, with none of the additional permissions of
65 | this License applicable to that copy.
66 |
67 | 3. Object Code Incorporating Material from Library Header Files.
68 |
69 | The object code form of an Application may incorporate material from
70 | a header file that is part of the Library. You may convey such object
71 | code under terms of your choice, provided that, if the incorporated
72 | material is not limited to numerical parameters, data structure
73 | layouts and accessors, or small macros, inline functions and templates
74 | (ten or fewer lines in length), you do both of the following:
75 |
76 | a) Give prominent notice with each copy of the object code that the
77 | Library is used in it and that the Library and its use are
78 | covered by this License.
79 |
80 | b) Accompany the object code with a copy of the GNU GPL and this license
81 | document.
82 |
83 | 4. Combined Works.
84 |
85 | You may convey a Combined Work under terms of your choice that,
86 | taken together, effectively do not restrict modification of the
87 | portions of the Library contained in the Combined Work and reverse
88 | engineering for debugging such modifications, if you also do each of
89 | the following:
90 |
91 | a) Give prominent notice with each copy of the Combined Work that
92 | the Library is used in it and that the Library and its use are
93 | covered by this License.
94 |
95 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
96 | document.
97 |
98 | c) For a Combined Work that displays copyright notices during
99 | execution, include the copyright notice for the Library among
100 | these notices, as well as a reference directing the user to the
101 | copies of the GNU GPL and this license document.
102 |
103 | d) Do one of the following:
104 |
105 | 0) Convey the Minimal Corresponding Source under the terms of this
106 | License, and the Corresponding Application Code in a form
107 | suitable for, and under terms that permit, the user to
108 | recombine or relink the Application with a modified version of
109 | the Linked Version to produce a modified Combined Work, in the
110 | manner specified by section 6 of the GNU GPL for conveying
111 | Corresponding Source.
112 |
113 | 1) Use a suitable shared library mechanism for linking with the
114 | Library. A suitable mechanism is one that (a) uses at run time
115 | a copy of the Library already present on the user's computer
116 | system, and (b) will operate properly with a modified version
117 | of the Library that is interface-compatible with the Linked
118 | Version.
119 |
120 | e) Provide Installation Information, but only if you would otherwise
121 | be required to provide such information under section 6 of the
122 | GNU GPL, and only to the extent that such information is
123 | necessary to install and execute a modified version of the
124 | Combined Work produced by recombining or relinking the
125 | Application with a modified version of the Linked Version. (If
126 | you use option 4d0, the Installation Information must accompany
127 | the Minimal Corresponding Source and Corresponding Application
128 | Code. If you use option 4d1, you must provide the Installation
129 | Information in the manner specified by section 6 of the GNU GPL
130 | for conveying Corresponding Source.)
131 |
132 | 5. Combined Libraries.
133 |
134 | You may place library facilities that are a work based on the
135 | Library side by side in a single library together with other library
136 | facilities that are not Applications and are not covered by this
137 | License, and convey such a combined library under terms of your
138 | choice, if you do both of the following:
139 |
140 | a) Accompany the combined library with a copy of the same work based
141 | on the Library, uncombined with any other library facilities,
142 | conveyed under the terms of this License.
143 |
144 | b) Give prominent notice with the combined library that part of it
145 | is a work based on the Library, and explaining where to find the
146 | accompanying uncombined form of the same work.
147 |
148 | 6. Revised Versions of the GNU Lesser General Public License.
149 |
150 | The Free Software Foundation may publish revised and/or new versions
151 | of the GNU Lesser General Public License from time to time. Such new
152 | versions will be similar in spirit to the present version, but may
153 | differ in detail to address new problems or concerns.
154 |
155 | Each version is given a distinguishing version number. If the
156 | Library as you received it specifies that a certain numbered version
157 | of the GNU Lesser General Public License "or any later version"
158 | applies to it, you have the option of following the terms and
159 | conditions either of that published version or of any later version
160 | published by the Free Software Foundation. If the Library as you
161 | received it does not specify a version number of the GNU Lesser
162 | General Public License, you may choose any version of the GNU Lesser
163 | General Public License ever published by the Free Software Foundation.
164 |
165 | If the Library as you received it specifies that a proxy can decide
166 | whether future versions of the GNU Lesser General Public License shall
167 | apply, that proxy's public statement of acceptance of any version is
168 | permanent authorization for you to choose that version for the
169 | Library.
--------------------------------------------------------------------------------
/rentree_scolaire/datas/rentree_etablissements.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/rentree_scolaire/datas/rentree_etablissements.rds
--------------------------------------------------------------------------------
/rentree_scolaire/funs/descriptif_application.R:
--------------------------------------------------------------------------------
1 |
2 | #' Modal containing informations about the application
3 | #'
4 | #' @return a modal ui to use in \code{\link[shiny]{showModal}}
5 | # @export
6 | #'
7 | # @examples
8 | descriptif_application <- function() {
9 | modalDialog(
10 | title = "A propos de cette application",
11 | tags$div(
12 | class = "dreamrs",
13 | tags$b("Les données :"),
14 | tags$ul(
15 | tags$li(
16 | "Nous avons utilisé les données sur les établissements scolaires disponible sur",
17 | tags$a("data.gouv.fr",
18 | href = "https://www.data.gouv.fr/fr/datasets/adresse-et-geolocalisation-des-etablissements-denseignement-du-premier-et-second-degres/"),
19 | "Seul les établissements publics avec les noms les plus fréquents sont utilisés dans l'application."
20 | ),
21 | tags$li(
22 | "Les informations sur les personnages historiques proviennent de Wikipédia, et ont été obtenues via ",
23 | tags$a("l'API", href = "https://www.mediawiki.org/wiki/API:Search") , "et via ",
24 | tags$a("dbpedia", href = "http://wiki.dbpedia.org/"), "."
25 | )
26 | ),
27 | tags$b("Les packages :"),
28 | tags$ul(
29 | tags$li(tags$a("shiny", href = "https://shiny.rstudio.com/"), "pour l'application."),
30 | tags$li(tags$a("shinyWidgets", href = "https://github.com/dreamRs/shinyWidgets"), "pour l'amélioration de l'aspect visuel."),
31 | tags$li(tags$a("billboarder", href = "https://github.com/dreamRs/billboarder"), "pour les graphiques réalisés en D3js.")
32 | ),
33 | tags$b("particles.js :"),
34 | tags$div(
35 | "L'arrière plan a été réalisé avec la librairie JavaScript ",
36 | tags$a(
37 | href = "https://github.com/VincentGarreau/particles.js/", "particle.js"
38 | ), "développée par Vincent Garreau."
39 | ),
40 | br(),
41 | tags$b("Les auteurs :"),
42 | tags$p("Cette application a été développée par Fanny Meyer et Victor Perrier, vous pouvez nous suivre sur Twitter ici :"),
43 | tags$a(
44 | class = "btn btn-default", icon("twitter"), "@dreamRs",
45 | href = "https://twitter.com/dreamRs_fr", style = "background-color: #1DA1F2; color: #FFF;"
46 | ),
47 | tags$a(
48 | class = "btn btn-default", icon("twitter"), "@Fanny",
49 | href = "https://twitter.com/_mfaan", style = "background-color: #1DA1F2; color: #FFF;"
50 | ),
51 | tags$a(
52 | class = "btn btn-default", icon("twitter"), "@Victor",
53 | href = "https://twitter.com/_pvictorr?lang=fr", style = "background-color: #1DA1F2; color: #FFF;"
54 | ),
55 | tags$span("ou vous pouvez consulter notre site :", tags$a("dreamrs.fr", href = "https://www.dreamrs.fr/"))
56 | ),
57 | easyClose = TRUE, size = "l",
58 | footer = modalButton("Fermer")
59 | )
60 | }
61 |
62 |
63 |
--------------------------------------------------------------------------------
/rentree_scolaire/funs/summarise_etablissements.R:
--------------------------------------------------------------------------------
1 |
2 | #' Compute the number of schools by groups
3 | #'
4 | #' @param data data.table, data about French schools.
5 | #' @param by Character (input from Shiny), between \code{genre}, \code{siecle} and \code{category}.
6 | #' @param by_type Add type of school as grouping variable
7 | #'
8 | #' @return a data.table
9 | # @export
10 | #'
11 | # @examples
12 | summarise_etablissements <- function(data, by, by_type = FALSE) {
13 | data <- copy(data)
14 | if (!by_type) {
15 | if (by == "genre") {
16 | datproxy <- data[!is.na(genre), .N, by = list(x = genre)][match(genre_lib, x)]
17 | } else if (by == "siecle") {
18 | datproxy <- data[!is.na(siecle), .N, by = list(x = siecle)][match(siecles_lib, x)]
19 | } else if (by == "category") {
20 | datproxy <- data[!is.na(category), .N, by = list(x = category)][order(-N)][1:10]
21 | }
22 | color <- NULL
23 | } else {
24 | if (by == "genre") {
25 | datproxy <- data[!is.na(genre), .N, by = list(x = genre, type_etablissement)]
26 | datproxy <- dcast(data = datproxy, formula = x~type_etablissement, value.var = "N")
27 | datproxy <- datproxy[match(genre_lib, x)]
28 | } else if (by == "siecle") {
29 | datproxy <- data[!is.na(siecle), .N, by = list(x = siecle, type_etablissement)]
30 | datproxy <- dcast(data = datproxy, formula = x~type_etablissement, value.var = "N")
31 | datproxy <- datproxy[match(siecles_lib, x)]
32 | } else if (by == "category") {
33 | datproxy <- data[!is.na(category), .N, by = list(x = category, type_etablissement)]
34 | datproxy <- dcast(data = datproxy, formula = x~type_etablissement, value.var = "N")
35 | datproxy <- datproxy[order(rowSums(datproxy[, .SD, .SDcol = unname(type_etablissement)], na.rm = TRUE), decreasing = TRUE)][1:10]
36 | }
37 | datproxy <- datproxy[, .SD, .SDcols = c("x", type_etablissement_lib)]
38 |
39 | }
40 | return(datproxy)
41 | }
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/rentree_scolaire/global.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | # ------------------------------------------------------------------------
4 | #
5 | # Title : App - Global
6 | # By : dreamRs
7 | # Date : dimanche 24 septembre 2017
8 | #
9 | # ------------------------------------------------------------------------
10 |
11 |
12 |
13 | # Packages ----------------------------------------------------------------
14 |
15 | if (!require("billboarder")) install.packages("billboarder")
16 | if (!require("data.table")) install.packages("data.table")
17 | if (!require("shinyWidgets")) install.packages("shinyWidgets")
18 | if (!require("jsonlite")) install.packages("jsonlite")
19 | if (!require("grDevices")) install.packages("grDevices")
20 |
21 |
22 |
23 | # Funs --------------------------------------------------------------------
24 |
25 | source("funs/summarise_etablissements.R")
26 | source("funs/descriptif_application.R", encoding = "UTF-8")
27 |
28 |
29 | # Datas -------------------------------------------------------------------
30 |
31 | rentree_etab <- readRDS(file = "datas/rentree_etablissements.rds")
32 |
33 |
34 | siecles_lib <- paste0(c("VIII", "XII", "XIII", "XV", "XVI", "XVII", "XVIII", "XIX", "XX"), "ième")
35 | genre_lib <- c("Femme", "Homme", "Inconnu")
36 |
37 | type_etablissement <- c(
38 | "Ecole élémentaire" = "Ecole élémentaire",
39 | "Collège" = "Collège",
40 | "Ecole maternelle" = "Ecole maternelle",
41 | "Lycée polyvalent" = "Lycée",
42 | "Lycée professionnel" = "Lycée",
43 | "Section d'enseignement général et professionnel adapté" = "Autre",
44 | "Lycée d'enseignement général et technologique" = "Lycée",
45 | "Lycée d'enseignement général" = "Lycée",
46 | "Etablissement régional d'enseignement adapté" = "Autre",
47 | "Ecole élémentaire d'application" = "Ecole élémentaire",
48 | "Ecole sans effectif permanent" = "Autre",
49 | "Section d'enseignement professionnel" = "Autre",
50 | "Ecole maternelle d'application" = "Ecole maternelle",
51 | "Lycée d'enseignement technologique" = "Lycée",
52 | "Ecole régionale du premier degré" = "Autre",
53 | "Ecole élémentaire spécialisée" = "Ecole élémentaire",
54 | "Etablissement expérimental" = "Autre",
55 | "Ecole élémentaire annexe d'ESPE" = "Ecole élémentaire"
56 | )
57 | names(type_etablissement) <- enc2utf8(names(type_etablissement))
58 | type_etablissement <- enc2utf8(type_etablissement)
59 |
60 | rentree_etab <- rentree_etab[, nature_uai_libe := iconv(nature_uai_libe, from = "latin1", to = "UTF-8")]
61 | rentree_etab <- rentree_etab[, type_etablissement := unname(type_etablissement)[chmatch(x = nature_uai_libe, table = names(type_etablissement))]]
62 |
63 | type_etablissement_lib <- enc2utf8(c("Ecole maternelle", "Ecole élémentaire", "Collège", "Lycée", "Autre"))
64 |
65 |
66 |
67 |
68 | # session_info ------------------------------------------------------------
69 |
70 | # sink("rentree_scolaire/session_info.txt")
71 | # devtools::session_info()
72 | # sink()
73 |
74 |
--------------------------------------------------------------------------------
/rentree_scolaire/server.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | # ------------------------------------------------------------------------
4 | #
5 | # Title : App - Server
6 | # By : dreamRs
7 | # Date : dimanche 24 septembre 2017
8 | #
9 | # ------------------------------------------------------------------------
10 |
11 | library(shiny)
12 |
13 | function(input, output, session) {
14 |
15 | output$bb_etablissements <- renderBillboarder({
16 | billboarder() %>%
17 | bb_barchart(data = rentree_etab[!is.na(genre), .N, by = list(x = genre)][match(genre_lib, x)], color = "#112446") %>%
18 | bb_y_grid(show = TRUE) %>%
19 | bb_y_axis(label = list(text = "# d'établissements", position = "outer-top")) %>%
20 | bb_legend(show = FALSE) %>%
21 | bb_data(selection = list(enabled = TRUE)) %>%
22 | bb_labs(title = "",
23 | caption = "Data source: DataGouv & Wikipedia")
24 | })
25 |
26 | observeEvent(list(input$indicateur, input$type_etablissement), {
27 |
28 | dat <- copy(rentree_etab)
29 | datproxy <- summarise_etablissements(dat, input$indicateur, input$type_etablissement)
30 |
31 | color <- if (input$type_etablissement){
32 | grDevices::colorRampPalette(c("#DEEBF7", "#112446"))(5)
33 | } else {
34 | NULL
35 | }
36 |
37 | billboarderProxy(shinyId = "bb_etablissements") %>%
38 | bb_unload() %>%
39 | bb_barchart(data = datproxy, color = color)
40 |
41 | if (input$type_etablissement) {
42 | billboarderProxy(shinyId = "bb_etablissements") %>% bb_proxy_legend("show")
43 | } else {
44 | billboarderProxy(shinyId = "bb_etablissements") %>% bb_proxy_legend("hide")
45 | }
46 |
47 | }, ignoreInit = FALSE)
48 |
49 |
50 | filtres_click <- reactiveValues(genre = character(0), category = character(0), siecle = character(0))
51 | observeEvent(input$bb_etablissements_click, {
52 | if (any(input$bb_etablissements_click$category %in% unique(rentree_etab$genre))) {
53 | filtres_click$genre <- input$bb_etablissements_click$category
54 | }
55 | if (any(input$bb_etablissements_click$category %in% unique(rentree_etab$category))) {
56 | filtres_click$category <- input$bb_etablissements_click$category
57 | }
58 | if (any(input$bb_etablissements_click$category %in% unique(rentree_etab$siecle))) {
59 | filtres_click$siecle <- input$bb_etablissements_click$category
60 | }
61 | filtres_click$x <- c(filtres_click$genre, filtres_click$category, filtres_click$siecle)
62 | })
63 |
64 | output$filtres_ui <- renderUI({
65 | if (length(filtres_click$x) > 0) {
66 | resfiltres <- lapply(
67 | X = filtres_click$x,
68 | FUN = function(x) {
69 | if (any(x %in% unique(rentree_etab$genre))) {
70 | nom_filtre <- "genre"
71 | label_filtre <- "Genre"
72 | } else if (any(x %in% unique(rentree_etab$category))) {
73 | nom_filtre <- "category"
74 | label_filtre <- "Activité"
75 | } else if (any(x %in% unique(rentree_etab$siecle))) {
76 | nom_filtre <- "siecle"
77 | label_filtre <- "Siècle"
78 | }
79 | actionLink(
80 | inputId = paste0("remove_", nom_filtre),
81 | label = paste(label_filtre, x, sep = " : "),
82 | icon = icon("remove"),
83 | style = "color: #112446; padding: 5px;"
84 | )
85 | }
86 | )
87 | tagList(tags$span("Filtres actifs :"), resfiltres)
88 | } else {
89 | tags$em("Cliquez sur le graphique ci-dessus pour ajouter un filtre à la sélection et mettre à jour le graphique ci-dessous.")
90 | }
91 | })
92 |
93 | observeEvent(input[["remove_genre"]], {
94 | filtres_click$genre <- character(0)
95 | filtres_click$x <- setdiff(filtres_click$x, unique(rentree_etab$genre))
96 | })
97 | observeEvent(input[["remove_category"]], {
98 | filtres_click$category <- character(0)
99 | filtres_click$x <- setdiff(filtres_click$x, unique(rentree_etab$category))
100 | })
101 | observeEvent(input[["remove_siecle"]], {
102 | filtres_click$siecle <- character(0)
103 | filtres_click$x <- setdiff(filtres_click$x, unique(rentree_etab$siecle))
104 | })
105 |
106 |
107 | output$bb_personnages <- renderBillboarder({
108 | dat2 <- copy(rentree_etab)
109 | dat2 <- dat2[, .N, by = list(x = NOM_LIB, genre)][order(-N)][1:12]
110 |
111 | dat3 <- dcast(data = dat2, formula = x~genre, value.var = "N")
112 |
113 | dat3 <- dat3[order(rowSums(dat3[, list(Inconnu, Femme, Homme)], na.rm = TRUE), decreasing = TRUE)]
114 |
115 | billboarder() %>%
116 | bb_barchart(data = dat3, color = "#112446", stacked = TRUE, rotated = TRUE) %>%
117 | bb_colors_manual(Femme = "#112446", Homme = "#77879E", Inconnu = "#CAD5DB") %>%
118 | bb_y_grid(show = TRUE) %>%
119 | bb_y_axis(label = list(text = "# d'établissements", position = "outer-top")) %>%
120 | bb_legend(hide = FALSE) %>%
121 | bb_data(selection = list(enabled = TRUE, multiple = FALSE)) %>%
122 | bb_tooltip(
123 | name = htmlwidgets::JS("function(name, ratio, id, index) {return 'N';}")
124 | ) %>%
125 | bb_labs(title = "Noms portés par les établissements",
126 | caption = "Data source: DataGouv & Wikipedia")
127 | })
128 |
129 | observeEvent(filtres_click$x, {
130 | dat2 <- copy(rentree_etab)
131 | if (any(filtres_click$x %in% unique(rentree_etab$genre))) {
132 | dat2 <- dat2[genre %in% filtres_click$x & !is.na(genre)]
133 | }
134 | if (any(filtres_click$x %in% unique(rentree_etab$category))) {
135 | dat2 <- dat2[category %in% filtres_click$x & !is.na(category)]
136 | }
137 | if (any(filtres_click$x %in% unique(rentree_etab$siecle))) {
138 | dat2 <- dat2[siecle %in% filtres_click$x & !is.na(siecle)]
139 | }
140 |
141 | dat2 <- dat2[, .N, by = list(x = NOM_LIB, genre)][order(-N)][1:12]
142 | dat2 <- dat2[!is.na(x)]
143 |
144 | if (nrow(dat2) == 0) {
145 | billboarderProxy(shinyId = "bb_personnages") %>% bb_barchart(data = data.table(x = "", Femme = 0, Homme = 0, Inconnu = 0))
146 | } else {
147 | dat3 <- dcast(data = dat2, formula = x~genre, value.var = "N")
148 |
149 | if (is.null(dat3$Inconnu)){
150 | dat3 <- dat3[, Inconnu := NA]
151 | }
152 | if (is.null(dat3$Femme)){
153 | dat3 <- dat3[, Femme := NA]
154 | }
155 | if (is.null(dat3$Homme)){
156 | dat3 <- dat3[, Homme := NA]
157 | }
158 |
159 | dat3 <- dat3[order(rowSums(dat3[, list(Inconnu, Femme, Homme)], na.rm = TRUE), decreasing = TRUE)]
160 |
161 | billboarderProxy(shinyId = "bb_personnages") %>%
162 | bb_barchart(data = dat3)
163 | }
164 | })
165 |
166 |
167 | observeEvent(input$bb_personnages_click$category, {
168 | ind <- which(rentree_etab$NOM_LIB %chin% input$bb_personnages_click$category)
169 | if (length(ind) > 0) {
170 | bio <- rentree_etab[ind[1], list(thumbnail, abstract)]
171 | if (bio$abstract != "") {
172 | modalContent <- fluidRow(
173 | column(
174 | width = 4,
175 | tags$img(src = bio$thumbnail, class="img-thumbnail")
176 | ),
177 | column(
178 | width = 8,
179 | tags$p(bio$abstract, style = "text-align: justify; text-justify: inter-word;")
180 | )
181 | )
182 | } else {
183 | modalContent <- tags$p("Désolé, pas d'infos...")
184 | }
185 | showModal(modalDialog(
186 | title = input$bb_personnages_click$category,
187 | modalContent,
188 | easyClose = TRUE, size = "l",
189 | footer = modalButton("Fermer")
190 | ))
191 | }
192 | })
193 |
194 |
195 | observeEvent(input$en_savoir_plus, {
196 | showModal(descriptif_application())
197 | })
198 |
199 | shiny::onStop(function() {
200 | rm(list = c("descriptif_application", "genre_lib", "rentree_etab", "siecles_lib",
201 | "summarise_etablissements", "type_etablissement", "type_etablissement_lib"
202 | ), envir = globalenv())
203 | shiny::stopApp()
204 | })
205 | }
206 |
207 |
--------------------------------------------------------------------------------
/rentree_scolaire/session_info.txt:
--------------------------------------------------------------------------------
1 | setting value
2 | version R version 3.4.2 (2017-09-28)
3 | system x86_64, mingw32
4 | ui RStudio (1.1.383)
5 | language (EN)
6 | collate French_France.1252
7 | tz Europe/Berlin
8 | date 2017-10-25
9 |
10 | package * version date source
11 | base * 3.4.2 2017-09-28 local
12 | billboarder * 0.1.0 2017-10-20 CRAN (R 3.4.2)
13 | colorspace 1.3-2 2016-12-14 CRAN (R 3.4.2)
14 | compiler 3.4.2 2017-09-28 local
15 | data.table * 1.10.4-2 2017-10-12 CRAN (R 3.4.2)
16 | datasets * 3.4.2 2017-09-28 local
17 | devtools 1.13.3 2017-08-02 CRAN (R 3.4.2)
18 | digest 0.6.12 2017-01-27 CRAN (R 3.4.2)
19 | ggplot2 2.2.1 2016-12-30 CRAN (R 3.4.2)
20 | graphics * 3.4.2 2017-09-28 local
21 | grDevices * 3.4.2 2017-09-28 local
22 | grid 3.4.2 2017-09-28 local
23 | gtable 0.2.0 2016-02-26 CRAN (R 3.4.2)
24 | htmltools 0.3.6 2017-04-28 CRAN (R 3.4.2)
25 | htmlwidgets 0.9 2017-07-10 CRAN (R 3.4.2)
26 | httpuv 1.3.5 2017-07-04 CRAN (R 3.4.2)
27 | jsonlite * 1.5 2017-06-01 CRAN (R 3.4.2)
28 | lazyeval 0.2.0 2016-06-12 CRAN (R 3.4.2)
29 | magrittr 1.5 2014-11-22 CRAN (R 3.4.2)
30 | memoise 1.1.0 2017-04-21 CRAN (R 3.4.2)
31 | methods * 3.4.2 2017-09-28 local
32 | mime 0.5 2016-07-07 CRAN (R 3.4.1)
33 | munsell 0.4.3 2016-02-13 CRAN (R 3.4.2)
34 | plyr 1.8.4 2016-06-08 CRAN (R 3.4.2)
35 | R6 2.2.2 2017-06-17 CRAN (R 3.4.2)
36 | Rcpp 0.12.13 2017-09-28 CRAN (R 3.4.2)
37 | rlang 0.1.2 2017-08-09 CRAN (R 3.4.2)
38 | scales 0.5.0 2017-08-24 CRAN (R 3.4.2)
39 | shiny * 1.0.5 2017-08-23 CRAN (R 3.4.2)
40 | shinyWidgets * 0.3.6 2017-10-19 CRAN (R 3.4.2)
41 | stats * 3.4.2 2017-09-28 local
42 | tibble 1.3.4 2017-08-22 CRAN (R 3.4.2)
43 | tools 3.4.2 2017-09-28 local
44 | utils * 3.4.2 2017-09-28 local
45 | withr 2.0.0 2017-07-28 CRAN (R 3.4.2)
46 | xtable 1.8-2 2016-02-05 CRAN (R 3.4.2)
47 | yaml 2.1.14 2016-11-12 CRAN (R 3.4.2)
48 |
--------------------------------------------------------------------------------
/rentree_scolaire/ui.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | # ------------------------------------------------------------------------
4 | #
5 | # Title : App - UI
6 | # By : dreamRs
7 | # Date : dimanche 24 septembre 2017
8 | #
9 | # ------------------------------------------------------------------------
10 |
11 | library(shiny)
12 |
13 | fluidPage(
14 |
15 | tags$head(
16 | # styles css
17 | tags$link(rel="stylesheet", type="text/css", href="styles.css"),
18 | # Particles background
19 | tags$script(src = "particles.min.js"),
20 | # Google font
21 | # tags$link(href="https://fonts.googleapis.com/css?family=Roboto", rel="stylesheet")
22 | tags$link(href="https://fonts.googleapis.com/css?family=Lora", rel="stylesheet")
23 | ),
24 |
25 | tags$scrip("$('body').attr('id', 'particles-js');"),
26 | tags$script(src = "app.js"),
27 |
28 | tags$div(
29 | class = "container",
30 |
31 |
32 | tags$h2(
33 | style = "text-align: center; color: #FFF; text-weight: bold;",
34 | "C'est la rentrée !"
35 | ),
36 | br(),
37 |
38 | panel(
39 | status = "primary",
40 | style = "background-color: #FFF; border-radius: 50px;",
41 | tags$div(
42 | style = "display: none;", icon("home")
43 | ),
44 | tags$p(
45 | "Cette année, plus de 12 millions d’élèves ont fait leur rentrée dans plus de 60 000 écoles, collèges et lycées. ",
46 | "Tout le monde connait au moins un collège Victor Hugo ... Mais vous êtes-vous déjà intéressé aux noms des établissements ?",
47 | "Cette application vous permet d'explorer les noms des établissements scolaires français (tout du moins les 35% avec les noms les plus fréquents).",
48 | "Vous pouvez choisir entre 3 axes d'analyse :",
49 | tags$ul(
50 | tags$li(
51 | tags$b("Genre :"), "le sexe de la personnalité, celui-ci peut être 'Inconnu' lorsqu'il s'agit d'un lieu ou",
52 | " que l'information n'était pas disponible dans la base Wikipédia."
53 | ),
54 | tags$li(
55 | tags$b("Siècle :"), "le siècle dans lequel est née la personnalité."
56 | ),
57 | tags$li(
58 | tags$b("Activité :"), "l'activité principale de la personnalité : écrivain, scientifique, ..."
59 | )
60 | ),
61 | "Les données sur les établissements scolaires proviennent de data.gouv (seuls les établissements publics sont pris en compte),",
62 | " les informations complémenataires proviennent",
63 | " de Wikipédia."
64 | ),
65 | fluidRow(
66 | column(
67 | width = 3,
68 | br(),
69 | tags$style(".btn-group-vertical {width: 100%;}"),
70 | radioGroupButtons(
71 | inputId = "indicateur",
72 | label = "Classer les noms d'établissements par :",
73 | choiceNames = list(
74 | tags$span(icon("venus-mars"), "Genre"),
75 | tags$span(icon("clock-o"), "Siècle"),
76 | tags$span(icon("graduation-cap"), "Activité")
77 | ),
78 | choiceValues = c("genre", "siecle", "category"),
79 | status = "dreamrs", justified = FALSE, selected = "genre", direction = "vertical"
80 | ),
81 | br(),
82 | materialSwitch(inputId = "type_etablissement", label = "Afficher par type d'établissement :", value = FALSE, status = "primary")
83 | ),
84 | column(
85 | width = 9,
86 | billboarderOutput(outputId = "bb_etablissements")
87 | )
88 | ),
89 | br(),
90 | uiOutput(outputId = "filtres_ui"),
91 | br(),
92 | billboarderOutput(outputId = "bb_personnages", height = "450px"),
93 | tags$em("Cliquez sur une barre pour avoir plus d'informations sur la personnalité."),
94 | br(), br(),
95 | actionLink(
96 | inputId = "en_savoir_plus", label = " à propos de l'application", icon = NULL,
97 | tags$img(src = "logo_dreamRs_couleur.png", style = "width: 50px; float:left; margin-right: 10px;"),
98 | style = "color: #112446; padding: 5px; line-height:25px;", class = "pull-right"
99 | )
100 | )
101 | )
102 |
103 | )
104 |
105 |
--------------------------------------------------------------------------------
/rentree_scolaire/www/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | particles.js License
3 | ----------------------------------------------------------------------
4 |
5 | The MIT License (MIT)
6 |
7 | Copyright (c) 2015, Vincent Garreau
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 |
--------------------------------------------------------------------------------
/rentree_scolaire/www/app.js:
--------------------------------------------------------------------------------
1 | /* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
2 | particlesJS.load('particles-js', 'particlesjs-config.json', function() {
3 | console.log('callback - particles.js config loaded');
4 | });
5 |
--------------------------------------------------------------------------------
/rentree_scolaire/www/logo_dreamRs_couleur.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/rentree_scolaire/www/logo_dreamRs_couleur.png
--------------------------------------------------------------------------------
/rentree_scolaire/www/particlesjs-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "particles": {
3 | "number": {
4 | "value": 160,
5 | "density": {
6 | "enable": true,
7 | "value_area": 800
8 | }
9 | },
10 | "color": {
11 | "value": "#ffffff"
12 | },
13 | "shape": {
14 | "type": "circle",
15 | "stroke": {
16 | "width": 0,
17 | "color": "#000000"
18 | },
19 | "polygon": {
20 | "nb_sides": 5
21 | },
22 | "image": {
23 | "src": "img/github.svg",
24 | "width": 100,
25 | "height": 100
26 | }
27 | },
28 | "opacity": {
29 | "value": 1,
30 | "random": true,
31 | "anim": {
32 | "enable": true,
33 | "speed": 1,
34 | "opacity_min": 0,
35 | "sync": false
36 | }
37 | },
38 | "size": {
39 | "value": 3,
40 | "random": true,
41 | "anim": {
42 | "enable": false,
43 | "speed": 4,
44 | "size_min": 0.3,
45 | "sync": false
46 | }
47 | },
48 | "line_linked": {
49 | "enable": false,
50 | "distance": 150,
51 | "color": "#ffffff",
52 | "opacity": 0.4,
53 | "width": 1
54 | },
55 | "move": {
56 | "enable": true,
57 | "speed": 1,
58 | "direction": "none",
59 | "random": true,
60 | "straight": false,
61 | "out_mode": "out",
62 | "bounce": false,
63 | "attract": {
64 | "enable": false,
65 | "rotateX": 600,
66 | "rotateY": 600
67 | }
68 | }
69 | },
70 | "interactivity": {
71 | "detect_on": "canvas",
72 | "events": {
73 | "onhover": {
74 | "enable": true,
75 | "mode": "bubble"
76 | },
77 | "onclick": {
78 | "enable": true,
79 | "mode": "repulse"
80 | },
81 | "resize": true
82 | },
83 | "modes": {
84 | "grab": {
85 | "distance": 400,
86 | "line_linked": {
87 | "opacity": 1
88 | }
89 | },
90 | "bubble": {
91 | "distance": 250,
92 | "size": 0,
93 | "duration": 2,
94 | "opacity": 0,
95 | "speed": 3
96 | },
97 | "repulse": {
98 | "distance": 400,
99 | "duration": 0.4
100 | },
101 | "push": {
102 | "particles_nb": 4
103 | },
104 | "remove": {
105 | "particles_nb": 2
106 | }
107 | }
108 | },
109 | "retina_detect": true
110 | }
--------------------------------------------------------------------------------
/rentree_scolaire/www/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/rentree_scolaire/www/screenshot.png
--------------------------------------------------------------------------------
/rentree_scolaire/www/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | /*font-family: Georgia, "Times New Roman", Times, serif !important;*/
3 | /*font-family: 'Roboto', sans-serif !important;*/
4 | font-family: 'Lora', serif !important;
5 | background-color: #112446;
6 | }
7 |
8 | .dreamrs {
9 | background-image:url(logo_dreamRs_couleur.png);
10 | background-repeat:no-repeat;
11 | background-position:right bottom;
12 | background-size: 156px 100px;
13 | }
14 |
15 | .material-switch > input[type="checkbox"]:checked + label::after {
16 | background: #112446;
17 | }
18 |
19 | .btn-dreamrs {
20 | background-color: #112446;
21 | color: #fff;
22 | border-color: #112446;
23 | }
24 |
25 | .btn-dreamrs:hover {
26 | color: #fff;
27 | }
28 |
29 | .btn-dreamrs.active {
30 | color: #112446;
31 | background-color: #fff;
32 | border-color: #112446;
33 | }
34 |
35 | .bootstrap-switch .bootstrap-switch-handle-off.bootstrap-switch-primary, .bootstrap-switch .bootstrap-switch-handle-on.bootstrap-switch-primary {
36 | color: #fff;
37 | background: #112446 !important;
38 | }
39 |
40 |
41 | .progress-bar-danger {
42 | background-color: #fff;
43 | }
44 |
45 | .progress-bar.progress-bar-danger {
46 | color: #000;
47 | }
48 |
49 | .progress {
50 | background-color: #c9cdd5;
51 | }
52 |
53 | #particles2-js canvas2{
54 | position: absolute;
55 | width: 95%;
56 | height: 100%;
57 | z-index: -1;
58 | }
59 |
60 | .container
61 | {
62 | position: absolute;
63 | top: 15px;
64 | width:90%;
65 | max-width: 1400px;
66 | min-width: 600px;
67 | margin: 0 auto;
68 | left: 0;
69 | right: 0;
70 | }
71 |
--------------------------------------------------------------------------------
/tdb-naissances/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .RData
4 | .Ruserdata
5 |
--------------------------------------------------------------------------------
/tdb-naissances/README.md:
--------------------------------------------------------------------------------
1 | # tdb-naissances
2 |
3 |
--------------------------------------------------------------------------------
/tdb-naissances/datas/contour_departements.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/tdb-naissances/datas/contour_departements.rds
--------------------------------------------------------------------------------
/tdb-naissances/datas/contour_regions.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/tdb-naissances/datas/contour_regions.rds
--------------------------------------------------------------------------------
/tdb-naissances/datas/naissances_departement.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/tdb-naissances/datas/naissances_departement.rds
--------------------------------------------------------------------------------
/tdb-naissances/datas/naissances_france.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/tdb-naissances/datas/naissances_france.rds
--------------------------------------------------------------------------------
/tdb-naissances/datas/naissances_region.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/tdb-naissances/datas/naissances_region.rds
--------------------------------------------------------------------------------
/tdb-naissances/global.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : Tableau de bord naissances - GLOBAL
5 | # By : dreamRs
6 | # Date : 2022-01-26
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 | # Packages -----------------------------------
12 |
13 | library(shiny)
14 | library(shinyWidgets)
15 | library(dplyr)
16 | library(apexcharter)
17 | library(leaflet)
18 | library(reactable)
19 | library(bslib)
20 | library(sf)
21 |
22 |
23 | # Datas --------------------------------------------------------------------
24 |
25 | naissances_france <- readRDS(file = "datas/naissances_france.rds")
26 | naissances_region <- readRDS(file = "datas/naissances_region.rds")
27 | naissances_departement <- readRDS(file = "datas/naissances_departement.rds")
28 |
29 | contour_regions <- readRDS(file = "datas/contour_regions.rds")
30 | contour_departements <- readRDS(file = "datas/contour_departements.rds")
31 |
--------------------------------------------------------------------------------
/tdb-naissances/screenshot_app_naissances.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamRs/shinyapps/5e0c21b4907ea17d458acf0a1651e38ecc8f37b8/tdb-naissances/screenshot_app_naissances.png
--------------------------------------------------------------------------------
/tdb-naissances/server.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : Tableau de bord naissances - SERVER
5 | # By : dreamRs
6 | # Date : 2022-01-26
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 |
11 | function(input, output, session) {
12 |
13 | # Filtre reactif sur le choix des données
14 | naissances_r <- reactive({
15 | if (input$niveau == "fra") {
16 | naissances_france
17 | } else if (input$niveau == "dep") {
18 | req(input$region_ou_dep %in% naissances_departement$GEO)
19 | naissances_departement %>%
20 | filter(GEO == input$region_ou_dep)
21 | } else {
22 | req(input$region_ou_dep %in% naissances_region$GEO)
23 | naissances_region %>%
24 | filter(GEO == input$region_ou_dep)
25 | }
26 | })
27 |
28 |
29 | ########## Première page : GENERAL ##########
30 |
31 | observeEvent(input$niveau, {
32 | if (input$niveau == "dep") {
33 | updateSelectInput(
34 | session,
35 | inputId = "region_ou_dep",
36 | label = "Département: ",
37 | choices = unique(naissances_departement$GEO)
38 | )
39 | } else if (input$niveau == "reg") {
40 | updateSelectInput(
41 | session,
42 | inputId = "region_ou_dep",
43 | label = "Région: ",
44 | choices = unique(naissances_region$GEO)
45 | )
46 | }
47 | })
48 |
49 |
50 | # Card 1 : "Nombre de naissances en 2020"
51 |
52 | observeEvent(naissances_r(), {
53 | valeur <- naissances_r() %>%
54 | filter(ANNEE == "2020") %>%
55 | pull(NBRE_NAISSANCES)
56 | updateStatiCard(
57 | id = "card_n_naissances",
58 | value = format(valeur, big.mark = " ")
59 | )
60 | })
61 |
62 |
63 | # Card 2 : "Taux de natalité en 2020"
64 |
65 | observeEvent(naissances_r(), {
66 | valeur <- naissances_r() %>%
67 | filter(ANNEE == "2020") %>%
68 | pull(TAUX_NATALITE)
69 | updateStatiCard(
70 | id = "card_natalite",
71 | value = valeur
72 | )
73 | })
74 |
75 |
76 | # Card 3 : "Pic de naissances"
77 |
78 | observeEvent(naissances_r(), {
79 | valeur <- naissances_r() %>%
80 | slice_max(NBRE_NAISSANCES, n = 1) %>%
81 | pull(ANNEE)
82 | updateStatiCard(
83 | value = valeur,
84 | id = "card_pic"
85 | )
86 | })
87 |
88 |
89 | # Courbe du "Nombre de naissances" avec le package apexcharter
90 |
91 | output$nombre_naissances_temps <- renderApexchart({
92 |
93 | # si le niveau geo choisit est la France on utilise les données aggrégées,
94 | # sinon l'objet reactif avec le département sélectionné ou la région séléctionnée
95 |
96 | apex(
97 | data = naissances_r(),
98 | type = "line",
99 | mapping = aes(x = as.Date(paste0(ANNEE, "-01-01"), format = "%Y-%m-%d"), y = NBRE_NAISSANCES)
100 | ) %>%
101 | ax_xaxis(labels = list(format = "yyyy")) %>%
102 | ax_tooltip(
103 | x = list(format = "yyyy")
104 | ) %>%
105 | ax_title(
106 | text = "Nombre de naissances entre 1975 et 2020"
107 | ) %>%
108 | ax_colors("#112446")
109 |
110 | })
111 |
112 | # Barplot "Taux de natalité" avec le package apexcharter
113 |
114 | output$taux_natalite <- renderApexchart({
115 |
116 | # si le niveau geo choisit est la France on utilise les données aggrégées,
117 | # sinon l'objet reactif avec le département sélectionné ou la région séléctionnée
118 |
119 | apex(
120 | data = naissances_r(),
121 | type = "column",
122 | mapping = aes(x = as.Date(paste0(ANNEE, "-01-01"), format = "%Y-%m-%d"), y = TAUX_NATALITE)
123 | ) %>%
124 | ax_xaxis(labels = list(format = "yyyy")) %>%
125 | ax_tooltip(
126 | x = list(format = "yyyy")
127 | ) %>%
128 | ax_title(
129 | text = "Taux de natalité"
130 | ) %>%
131 | ax_colors("#112446")
132 |
133 | })
134 |
135 |
136 | ########## Deuxième page : CARTE ##########
137 |
138 | # Initialisation de la carte avec Leaflet
139 |
140 | output$carte <- renderLeaflet({
141 | leaflet() %>%
142 | addTiles() %>%
143 | setView(
144 | lng = 2.80,
145 | lat = 46.80,
146 | zoom = 5
147 | ) %>%
148 | addProviderTiles(providers$OpenStreetMap.France)
149 | })
150 |
151 | # Mise à jour de la carte via proxy
152 |
153 | observe({
154 |
155 | input$tabs
156 |
157 | if (input$niveau_carte == "region") {
158 | contour <- contour_regions
159 | } else {
160 | contour <- contour_departements
161 | }
162 |
163 | if (input$variable == "Nombre de naissances") {
164 | valeurs <- contour %>%
165 | pull(NBRE_NAISSANCES)
166 | couleurs <- "Blues"
167 | popup <- "Nombre de naissances :"
168 | legende <- "Nombre de naissances en 2020"
169 | } else if (input$variable == "Taux de natalité") {
170 | valeurs <- contour %>%
171 | pull(TAUX_NATALITE)
172 | couleurs <- "Greens"
173 | popup <- "Taux de natalité :"
174 | legende <- "Taux de natalité en 2020"
175 | } else {
176 | valeurs <- contour %>%
177 | pull(AGE_MOYEN_MERE)
178 | couleurs <- "RdPu"
179 | popup <- "Âge moyen de la mère :"
180 | legende <- "Âge moyen de la mère en 2020"
181 | }
182 |
183 | pal <- colorNumeric(
184 | palette = couleurs,
185 | domain = valeurs
186 | )
187 |
188 | leafletProxy("carte") %>%
189 | clearShapes() %>%
190 | addPolygons(
191 | data = contour,
192 | fill = TRUE,
193 | fillColor = pal(valeurs),
194 | fillOpacity = 0.7,
195 | color = "#424242",
196 | opacity = 0.8,
197 | weight = 2,
198 | highlightOptions = highlightOptions(color = "white", weight = 2),
199 | popup = paste0(popup, valeurs)
200 | ) %>%
201 | clearControls() %>%
202 | addLegend(
203 | position = "bottomright",
204 | title = legende,
205 | pal = pal,
206 | values = valeurs,
207 | opacity = 1
208 | )
209 | })
210 |
211 |
212 | ########## Troisième page : DATA ##########
213 |
214 | # Affichage du tableau
215 | output$tableau_data <-renderReactable({
216 | reactable(naissances_r(), bordered = TRUE)
217 | })
218 |
219 | # Module d'export des données
220 | output$export_data <- downloadHandler(
221 | filename = function() {
222 | "export_naissances.csv"
223 | },
224 | content = function(file) {
225 | write.csv2(x = naissances_r(), file = file, row.names = FALSE)
226 | }
227 | )
228 |
229 | }
230 |
231 |
232 |
233 |
234 |
235 |
--------------------------------------------------------------------------------
/tdb-naissances/ui.R:
--------------------------------------------------------------------------------
1 |
2 | # ------------------------------------------------------------------------
3 | #
4 | # Title : Tableau de bord naissances - UI
5 | # By : dreamRs
6 | # Date : 2022-01-26
7 | #
8 | # ------------------------------------------------------------------------
9 |
10 | fluidPage(
11 |
12 | # Thème bslib
13 | theme = bs_theme (
14 | version = 5,
15 | bg = "#FFFFFF",
16 | fg = "#112446",
17 | primary = "#112446",
18 | "well-bg" = "#FFF",
19 | base_font = font_google("Poppins")
20 | ),
21 |
22 | h1("Les naissances en France", align = "center"),
23 |
24 | tags$head(
25 | # Custom CSS styles
26 | tags$link(rel="stylesheet", type="text/css", href="css_custom_styles.css"),
27 | ),
28 |
29 | navlistPanel(
30 | id = "tabs",
31 | selected = "Général",
32 | widths = c(2, 10),
33 |
34 | header = tagList(
35 |
36 | conditionalPanel(
37 | condition = "input.tabs == 'Général' | input.tabs == 'Data'",
38 |
39 | fluidRow(
40 | column(
41 | width = 9,
42 |
43 | radioGroupButtons(
44 | inputId = "niveau",
45 | label = "Afficher :",
46 | choices = list(
47 | "France" = "fra",
48 | "Région" = "reg",
49 | "Département" = "dep"),
50 | selected = "fra",
51 | justified = TRUE
52 | )
53 | ),
54 |
55 | column(
56 | width = 3,
57 |
58 | conditionalPanel(
59 | condition = "input.niveau == 'dep' | input.niveau == 'reg'",
60 | selectizeInput(
61 | inputId = "region_ou_dep",
62 | label = NULL,
63 | choices = NULL
64 | )
65 | )
66 |
67 | )
68 | )
69 | )
70 | ),
71 |
72 |
73 | ########## Première page : GENERAL ##########
74 |
75 | tabPanel(
76 | title = "Général",
77 |
78 | fluidRow(
79 | column(
80 | width = 4,
81 | statiCard(
82 | value = 0,
83 | subtitle = "Nombre de naissances en 2020",
84 | icon = icon("child"),
85 | color = "#112446",
86 | animate = TRUE,
87 | id = "card_n_naissances"
88 | )
89 | ),
90 |
91 | column(
92 | width = 4,
93 | statiCard(
94 | value = 0,
95 | subtitle = "Taux de natalité en 2020",
96 | icon = icon("chart-line"),
97 | color = "#112446",
98 | animate = TRUE,
99 | id = "card_natalite"
100 | )
101 | ),
102 | column(
103 | width = 4,
104 | statiCard(
105 | value = 0,
106 | subtitle = "Pic de naissances",
107 | icon = icon("arrow-up"),
108 | color = "#112446",
109 | animate = TRUE,
110 | id = "card_pic"
111 | )
112 | )
113 | ),
114 |
115 | fluidRow(
116 |
117 | column(
118 | width = 6,
119 | apexchartOutput(outputId = "nombre_naissances_temps")
120 | ),
121 | column(
122 | width = 6,
123 | apexchartOutput(outputId = "taux_natalite")
124 | )
125 | )
126 | ),
127 |
128 |
129 | ########## Deuxième page : CARTE ##########
130 |
131 | tabPanel(
132 | title = "Carte",
133 |
134 | fluidRow(
135 |
136 | column(
137 | width = 9,
138 | radioGroupButtons(
139 | inputId = "niveau_carte",
140 | label = "Afficher :",
141 | choices = list("Région" = "region", "Département" = "departement"),
142 | selected = "region",
143 | justified = TRUE
144 | )
145 | ),
146 |
147 | column(
148 | width = 3,
149 | awesomeRadio(
150 | inputId = "variable",
151 | label = "Choix de la variable :",
152 | choices = list(
153 | "Nombre de naissances",
154 | "Taux de natalité",
155 | "Âge moyen de la mère"),
156 | selected = "Nombre de naissances"
157 | )
158 | )
159 | ),
160 |
161 | br(),
162 |
163 | leafletOutput(outputId = "carte", width = "100%", height = 600)
164 |
165 | ),
166 |
167 | ########## Troisième page : DATA ##########
168 |
169 | tabPanel(
170 | title = "Data",
171 | downloadButton(outputId = "export_data", label = "Exporter", class = "mb-3"),
172 | reactableOutput(outputId = "tableau_data")
173 | )
174 | )
175 | )
176 |
177 |
178 |
--------------------------------------------------------------------------------
/tdb-naissances/www/css_custom_styles.css:
--------------------------------------------------------------------------------
1 | /* Custom CSS styles */
2 |
3 | .well {
4 | height: fit-content !important;
5 | }
6 |
7 | .nav.nav-stacked {
8 | height: auto !important;
9 | }
10 |
11 | .container-fluid {
12 | max-width: 1600px;
13 | margin: auto;
14 | }
--------------------------------------------------------------------------------