knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(occupationparkingsapp) library(R6) library(xtradata) library(tidytable) library(lubridate) library(timetk) library(ggplot2) library(dplyr) library(ggiraph)
On va définir une classe R6, qui va permettre d'effecteur les opérations suivantes sur les différents types de parkings (relais ou non) et secteurs d'intéret (hypercentre, centre, périphérie).
Cette classe va devoir réaliser les opérations suivantes :
pkgload::load_all() parc_relais_hour <- Occupation$new(rangeStart = Sys.Date() - 3, rangeEnd = Sys.Date() - 1, localisation_parking = NA, parc_relais = TRUE) centre_day <- Occupation$new(rangeStart = Sys.Date() - 3, rangeEnd = Sys.Date() - 1, localisation_parking = "centre", parc_relais = FALSE)
parc_relais_hour$download_data(rangeStep = "hour") centre_day$download_data(rangeStep = "day")
Le choix du rangeStep est des opérations qui vont en découler vont dépendre du choix de l'utilisateur.
-> données horaires rangeStep = hour dataviz = moyenne horaire sur la plage de temps complète
-> données journalières rangeStep = day dataviz = données rendues par xtradata jour par jour
-> données hebdo rangeStep = day dataviz = données à agreger à la semaine (moyenne)
-> données mensuelle rangeStep = day dataviz = données à agreger au mois (moyenne)
-> données annuelle rangeStep = day dataviz = données à agreger à l'année (moyenne)
-> faire du cache là dessus
head(parc_relais_hour$data_xtradata) # on souhaite garder dans l'output final # ident # time # libres # total
parc_relais_hour$clean_output() head(parc_relais_hour$data_xtradata) centre_day$clean_output() head(centre_day$data_xtradata)
parc_relais_hour$mean_by_some_time_unit(time_unit = "hour") head(parc_relais_hour$data_xtradata) centre_day$mean_by_some_time_unit(time_unit = "day") head(centre_day$data_xtradata)
# ggplot(data = centre_day$data_xtradata, mapping = aes(x = time, y = taux_occupation, color = ident)) + # geom_line() # # ggplot(data = parc_relais_hour$data_xtradata, mapping = aes(x = time, y = taux_occupation, color = ident)) + # geom_line() centre_day$timeseries_plot() parc_relais_hour$timeseries_plot()
De manière identique on va créer une classe R6 dediée. Récupération de données, nettoyage et graphe.
En l'état on ne peut récupérer qu'une semaine via le WS. On reste là dessus.
source("../R/Saturation.R") parc_relais_hour <- Saturation$new(rangeStart = as.Date("2021-05-24"), rangeEnd = as.Date("2021-05-31"), localisation_parking = NA, parc_relais = TRUE)
parc_relais_hour$download_data(rangeStep = "hour")
parc_relais_hour$clean_output()
parc_relais_hour$data_xtradata parc_relais_hour$filter_full_capacity_parkings() parc_relais_hour$calendar_heatmap() ggiraph::girafe(ggobj = gg) # nb heures / j ooù saturation >= 90%, et nb jours >= 2 / semaine
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.