├── rsconnect └── shinyapps.io │ └── achab94 │ └── covid-19.dcf ├── google-analytics.html ├── Info.md ├── README.md ├── LICENSE └── app.R /rsconnect/shinyapps.io/achab94/covid-19.dcf: -------------------------------------------------------------------------------- 1 | name: covid-19 2 | title: 3 | username: 4 | account: achab94 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 1935865 8 | bundleId: 2887166 9 | url: https://achab94.shinyapps.io/covid-19/ 10 | when: 1584377065.26126 11 | -------------------------------------------------------------------------------- /google-analytics.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /Info.md: -------------------------------------------------------------------------------- 1 | # Credits and informations 2 | 3 | --- 4 | 5 | ##### Author 6 | 7 | This platform was created by Emanuele Degani [(web)](https://achab94.github.io), PhD student at the Department of Statistical Sciences of the University of Padua. Suggestions, criticisms and reports of any bugs are strongly suggested at **degani [at] stat [dot] unipd [dot] it**. 8 | 9 | A big thanks to Emanuele Aliverti, Pietro Belloni, Laura D'Angelo, Nicola Pilia, Stefano Corona, Francesco Mancone for having contributed with valuable suggestions and criticisms. 10 | 11 | **Update (22nd March 2020)** : Giorgio Sestili, manager of the Facebook page [Coronavirus - Dati e Analisi Scientifiche](https://www.facebook.com/DatiAnalisiCoronavirus), interviewed me and we exchanged some words about this portal, on how it works and how it was born. I suggest you to follow their Facebook page to stay updated on scientifically reliable content on the evolution of the phenomenon. Sadly, that page and the following interview are both in italian. 12 | 13 | [](http://www.youtube.com/watch?v=4lCxc4fH8Ws "") 14 | 15 | **Update (16th March 2020)** : in the last few hours I have recorded a high number of accesses which has compromised the usability of the portal, given the limited computational resources made available by the free rate of the server. I therefore found myself forced to rent more computational resources to the provider (ShinyApps), for a monthly cost of 35 euros. I decided to ask a free offer to anyone wishing to contribute to the expenses, according to their availability, through a [MoneyBox Paypal](https://paypal.me/pools/c/8nqxplRvVc) which would automatically close as soon as the amount necessary would have been achieved (to avoid receiving further unnecessary offers). In less than two hours the total amount was reached: this was possible thanks to the donations of Guido Milano, Gianpaolo Natale, Franco Bocci, Enrico Bonan, Fabio Comini, Stefano De Lazzari. Thank you so much. 16 | 17 | --- 18 | 19 | ##### Data source 20 | 21 | The platform automatically takes the data, whenever a user logs in, from the latest updated version of the database [(link GitHub)](https://github.com/pcm-dpc/COVID-19) made available by the Civil Protection daily around at 18:30pm, immediately after the press conference of the Head of the Department of Civil Protection Angelo Borrelli. It is advisable to consult [this link](https://github.com/pcm-dpc/COVID-19/blob/master/README.md) for any information on the data available and on the data-entry (this is because often some data every day are missing, or arrive late). 22 | 23 | --- 24 | 25 | ##### How it was made 26 | 27 | The platform was created entirely in **R** language, using the features of the Shiny library [(website)](https://shiny.rstudio.com). Other libraries used are `ggplot2` and` ggiraph` (for interactive data-visualization), `dplyr` (for data-processing) and` shinyWidgets` (for some of the widgets included). 28 | The platform lies online on the computing space made available by ShinyApps [(website)](https://www.shinyapps.io). 29 | 30 | The whole code used to make this portal is available on [this Github repository](https://github.com/Achab94/monitoRing-COVID19). 31 | 32 | --- 33 | 34 | ##### License to use 35 | 36 |  37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # monitoRing-COVID19 2 | Portale di monitoraggio dell'evoluzione dell'epidemia COVID-19 in Italia. 3 | 4 | ## Descrizione 5 | 6 | La presente directory fa riferimento al portale [https://achab94.shinyapps.io/covid-19/](https://achab94.shinyapps.io/covid-19/). 7 | 8 | Il suo scopo è quello di monitorare l'andamento nazionale dell'[epidemia COVID-19](http://www.salute.gov.it/nuovocoronavirus) sul territorio nazionale italiano, elaborando i dati pubblicamente disponibili e quotidianamente aggiornati dalla Protezione Civile. Si prega di consultare il [sito della Protezione Civile](http://www.protezionecivile.it/attivita-rischi/rischio-sanitario/emergenze/coronavirus) per qualunque informazione circa i rischi e le misure di protezione legate all'espanzione dell'epidemia, e la [repository della Protezione Civile](https://github.com/pcm-dpc/COVID-19) per avere maggiori dettagli sui dati a disposizione online. 9 | 10 | La realizzazione è stata motivata dalle seguenti ragioni: 11 | - Disporre di uno strumento **facilmente utilizzabile**, **gratuito** ed **usufruibile a tutti** che consentisse di elaborare la grande quantità di dati resa disponibile quotidianamente dalla Protezione Civile; 12 | - Permettere all'utente di elaborare le proprie analisi in modo **interattivo**, a seconda delle proprie esigenze e del proprio interesse; 13 | - Fornire grafici e statistiche sull'andamento temporale di molteplici variabili di interesse, non solo a livello nazionale ma anche sulle dimensioni territoriali **regionali** e **provinciali**. La mia percezione è che queste siano decisamente più interessanti e significative di quelle osservate a livello nazionale, quotidianamente commentate da giornali e fonti di informazioni, che risultano dalla mera aggregazione di evoluzioni locali, con caratteristiche spesso molto eterogenee l'una con l'altrao. 14 | 15 | ## Caratteristiche e funzionalità 16 | 17 | Il portale, nella sua versione attuale pubblicamente rilasciata in data 14 Marzo 2020, è strutturato nelle seguenti schede: 18 | - *Evoluzione nazionale*: è la schermata principale, che svolge la funzione di *cruscotto informativo* sull'evoluzione nazionale del fenomeno. 19 | - *Evoluzione regionale*: questa scheramata permette di approfondire l'evoluzione del fenomeno nelle varie regioni d'Italia. Il pannello di sinistra consente l'interazione con l'utente, che può scegliere le regioni che intende studiare/confrontare (fino ad un massimo di 4, per ragioni di resa grafica), quale variabile d'interesse studiare, se visualizzarne i dati cumulati o quelli giornalieri, e su quale data esibire uno dei grafici mostrati a destra. La parte di destra esibisce un confronto delle variazioni relative quotidiane (da un giorno all'altro) su alcune variabili d'interesse, confrontate sulle regioni scelte (con un'interpretazione simile a quella del grafico fornito per l'Evoluzione Nazionale); il grafico con la suddivisione in un determinato giorno dei trattati positivi al COVID-19, confrontato sulle regioni scelte; il grafico con l'evoluzione temporale del fenomeno d'interesse, confrontato sulle regioni scelte. 20 | - *Evoluzione provinciale*: siccome l'unico dato disponibile sulla dimensione provinciale è quello del numero totale dei casi registrati in una determinata provincia, questa è l'unica informazione consultabile. Viene inoltre fornito un confronto con tutte le altre province appartenenti alle regioni alle quali afferiscono le province scelte. 21 | - *Informazioni*: è la pagina che fornisce ulteriori dettagli su chi ha realizzato il sito, chi ha collaborato, come è organizzato e come è stato realizzato. 22 | 23 | ## Realizzazione 24 | 25 | Il sito è stato completamente realizzato in linguaggio *R*, utilizzando la libreria [Shiny](https://shiny.rstudio.com), e attualmente risiede su uno spazio messo a disposizione da [ShinyApps](https://www.shinyapps.io). 26 | 27 | L'intero codice è consultabile all'interno del file *app.R* della presente repository. Il file è organizzato nella classica struttura di un file Shiny: una sezione sull'UI dell'applicativo (la veste grafica, dell'organizzazione delle sezioni e dei grafici prodotti) ed una seconda sezione relativa alle istruzioni da far compilare al server. 28 | 29 | ## Crediti 30 | 31 | Il sito è stato realizzato da Emanuele Degani [(website)](https://achab94.github.io), in condivisione di idee con altri colleghi citati nella sezione Info del portale. Per qualunque critica, suggerimento, dubbio od informazione, siete pregati di contattarmi all'indirizzo mail *emanuele [dot] achab [at] gmail [dot] com* od aprendo una Issues nella repository. 32 | 33 | 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /app.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(ggplot2) 3 | library(dplyr) 4 | library(shinythemes) 5 | library(scales) 6 | library(lubridate) 7 | library(shinyWidgets) 8 | library(reshape2) 9 | library(rmarkdown) 10 | library(ggiraph) 11 | library(DT) 12 | 13 | # instructions for updating 14 | # library(rsconnect) 15 | # rsconnect::deployApp("Dropbox/COVID-19/COVID-19/") 16 | 17 | # Definition of the User Interface ---------------------------------------- 18 | 19 | ui <- navbarPage(theme = shinytheme("flatly"), 20 | title = "Monitoring COVID-19 evolution in Italy", 21 | 22 | tabPanel("National evolution", 23 | div(style="margin-top:-3.5em", 24 | fluidRow( 25 | column(width=10, 26 | htmlOutput("headerCruscotto"), 27 | htmlOutput("summary"), 28 | style="padding:15px;") 29 | ) 30 | ), 31 | 32 | fluidPage( 33 | tags$head(includeHTML(("google-analytics.html")), 34 | tags$style(type="text/css", "text {font-family: arial, helvetica}")), 35 | # fluidRow(splitLayout(cellWidths = c("49%", "49%"), 36 | # ggiraphOutput("scatterMonitoraggioITA"), 37 | # ggiraphOutput("datiGiornalieriITA"))), 38 | # fluidRow(splitLayout(cellWidths = c("49%", "49%"), 39 | # ggiraphOutput("barPlotDeltaPercentualiITA"), 40 | # ggiraphOutput("scatterRapportoTotalePositiviTamponi"))), 41 | # fluidRow(splitLayout(cellWidths = c("49%", "49%"), 42 | # ggiraphOutput("evoluzioneTassi"), 43 | # ggiraphOutput("barPlotTrattamento"))) 44 | fluidRow(ggiraphOutput("scatterMonitoraggioITA")), 45 | fluidRow(ggiraphOutput("datiGiornalieriITA")), 46 | fluidRow(ggiraphOutput("barPlotDeltaPercentualiITA")), 47 | fluidRow(ggiraphOutput("scatterRapportoTotalePositiviTamponi")), 48 | fluidRow(ggiraphOutput("evoluzioneTassi")), 49 | fluidRow(ggiraphOutput("barPlotTrattamento")) 50 | ) 51 | ), 52 | tabPanel("Regional evolution", 53 | sidebarLayout( 54 | sidebarPanel( 55 | pickerInput( 56 | inputId = "selezionaRegioni", 57 | label = "Select the region(s) of interest (max 4)", 58 | choices = list("Northern Italy" = list("Lombardia", "Liguria", "Piemonte", "Valle d'Aosta", 59 | "Emilia-Romagna", "Friuli Venezia Giulia", "Veneto"), 60 | "Central Italy" = list("Lazio", "Marche", "Toscana", "Umbria"), 61 | "Sourhern Italy" = list("Abruzzo", "Basilicata", "Calabria", 62 | "Campania", "Molise", "Puglia"), 63 | "Insular" = list("Sardegna", "Sicilia")), 64 | selected = c("Lombardia", "Piemonte"), 65 | options = list( 66 | `actions-box` = FALSE, 67 | header = "Regions", 68 | `max-options` = 4, 69 | `max-options-text` = "Select 4 regions at maximum" 70 | ), 71 | multiple = TRUE 72 | ), 73 | 74 | helpText("Trentino Alto Adige does not communicate the regional data, this is why it does not appear among the list."), 75 | 76 | radioButtons("selezionaVariabileRegioni", 77 | label = "Select the variable of interest", 78 | choices = list("Total positive cases", 79 | "Currently positive patients", 80 | "Deceased patients", 81 | "Discharged/healed patients", 82 | "Hospitalized patients with symptoms", 83 | "Intensive care patients", 84 | "Home isolation patients", 85 | "Administered swabs", 86 | "Rate between positives and swabs made"), 87 | selected = "Total positive cases" 88 | ), 89 | 90 | materialSwitch(inputId = "giornalieroSiNoRegione", 91 | label = "View the daily data", 92 | status = "danger"), 93 | 94 | helpText("The graph on the left shows by default the combined count of currently infected patients. If you want to view 95 | the daily trend (how many new cases have been recorded each day), select the button."), 96 | 97 | uiOutput("selezionaGiornoRegio"), 98 | 99 | helpText("The chart on the right shows by default the current subdivision of the type of treatment for currently infected patients. 100 | If you want to view the evolution of the day-to-day breakdown, drag the button.") 101 | 102 | ), 103 | 104 | mainPanel(tags$style(type="text/css", 105 | ".shiny-output-error { visibility: hidden; }", 106 | ".shiny-output-error:before { visibility: hidden; }" 107 | ), 108 | verticalLayout( 109 | # fluidRow( 110 | # splitLayout(cellWidths = c("49%", "49%"), ggiraphOutput("scatterRegionale"), ggiraphOutput("barPlotDeltaPercentualiRegionale")) 111 | # ), 112 | # fluidRow( 113 | # splitLayout(cellWidths = c("49%", "49%"), ggiraphOutput("evoluzioneTassiRegionale"), ggiraphOutput("barPlotRegionale")) 114 | # ) 115 | fluidRow(ggiraphOutput("scatterRegionale")), 116 | fluidRow(ggiraphOutput("barPlotDeltaPercentualiRegionale")), 117 | fluidRow(ggiraphOutput("evoluzioneTassiRegionale")), 118 | fluidRow(ggiraphOutput("barPlotRegionale")) 119 | ) 120 | ) 121 | ) 122 | ), 123 | tabPanel("Provincial evolution", 124 | sidebarLayout( 125 | sidebarPanel( 126 | pickerInput( 127 | inputId = "selezionaProvincie", 128 | label = "Select the province(s) of interest (max 4)", 129 | choices = list("Abruzzo" = list("Chieti", "L'Aquila", "Pescara", "Teramo"), 130 | "Basilicata" = list("Matera", "Potenza"), 131 | "Calabria" = list("Catanzaro", "Cosenza", "Crotone", "Reggio di Calabria", "Vibo Valentia"), 132 | "Campania" = list("Avellino", "Benevento", "Caserta", "Napoli", "Salerno"), 133 | "Emilia-Romagna" = list("Bologna", "Ferrara", "Forlì-Cesena", "Modena", "Parma", "Piacenza", "Ravenna", "Reggio nell'Emilia", "Rimini"), 134 | "Friuli Venezia Giulia" = list("Gorizia", "Pordenone", "Trieste", "Udine"), 135 | "Lazio" = list("Frosinone", "Latina", "Rieti", "Roma", "Viterbo"), 136 | "Liguria" = list("Genova", "Imperia", "La Spezia", "Savona"), 137 | "Lombardia" = list("Bergamo", "Brescia", "Como", "Cremona", "Lecco", "Lodi", "Mantova", "Milano", "Monza e della Brianza", "Pavia", "Sondrio", "Varese"), 138 | "Marche" = list("Ancona", "Ascoli Piceno", "Fermo", "Macerata", "Pesaro e Urbino"), 139 | "Molise" = list("Campobasso", "Isernia"), 140 | "Piemonte" = list("Alessandria", "Asti", "Biella", "Cuneo", "Novara", "Torino", "Verbano-Cusio-Ossola", "Vercelli"), 141 | "Puglia" = list("Bari", "Barletta-Andria-Trani", "Brindisi", "Foggia", "Lecce", "Taranto"), 142 | "Sardegna" = list("Cagliari", "Nuoro", "Oristano", "Sassari", "Sud Sardegna"), 143 | "Sicilia" = list("Agrigento", "Caltanissetta", "Catania", "Enna", "Messina", "Palermo", "Ragusa", "Siracusa", "Trapani"), 144 | "Toscana" = list( "Arezzo", "Firenze", "Grosseto", "Livorno", "Lucca", "Massa Carrara", "Pisa", "Pistoia", "Prato", "Siena"), 145 | "Trentino-Alto Adige" = list("Bolzano", "Trento"), 146 | "Umbria" = list("Perugia", "Terni"), 147 | "Valle d'Aosta" = list("Aosta"), 148 | "Veneto" = list("Belluno", "Padova", "Rovigo", "Treviso", "Venezia", "Verona", "Vicenza")), 149 | selected = c("Bergamo", "Brescia", "Milano"), 150 | options = list( 151 | `actions-box` = FALSE, 152 | header = "Province", 153 | `max-options` = 5, 154 | `max-options-text` = "Select 5 regions at maximum" 155 | ), 156 | multiple = TRUE 157 | ), 158 | 159 | materialSwitch(inputId = "giornalieroSiNoProvincia", 160 | label = "View the daily data", 161 | status = "danger"), 162 | 163 | helpText("The graph on the left shows by default the combined count of the total of positives. If you want to view 164 | the daily trend (how many new positive cases have been recorded each day), select the button."), 165 | 166 | uiOutput("selezionaGiornoProv"), 167 | 168 | helpText("The chart on the right shows by default today's regional comparison of the number of total cases recorded. 169 | If you want to view the evolution day by day, drag the button.") 170 | 171 | ), 172 | 173 | mainPanel(tags$style(type="text/css", 174 | ".shiny-output-error { visibility: hidden; }", 175 | ".shiny-output-error:before { visibility: hidden; }" 176 | ), 177 | verticalLayout( 178 | fluidRow( 179 | splitLayout(cellWidths = c("49%", "49%"), ggiraphOutput("scatterProvinciale"), ggiraphOutput("barPlotProvinciale")) 180 | ), 181 | h3("Relative increase (%) in the number of positive cases between yesterday and today"), 182 | fluidRow( 183 | DTOutput("dfProvinceIncrementoMaggiore") 184 | ) 185 | ) 186 | ) 187 | ) 188 | ), 189 | tabPanel("Credits and informations", div(style="margin-top:-2.5em", includeMarkdown("Info.md"))) 190 | ) 191 | 192 | 193 | server <- function(input, output) { 194 | dataProvinceInput <- reactive({ 195 | storicoProvince <- read.csv(file = "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-province/dpc-covid19-ita-province.csv", stringsAsFactors = FALSE) 196 | storicoProvince <- subset(storicoProvince, denominazione_provincia!="In fase di definizione/aggiornamento") 197 | storicoProvince$denominazione_regione[storicoProvince$denominazione_regione %in% list("P.A. Trento", "P.A. Bolzano")] <- "Trentino-Alto Adige" 198 | 199 | myProvince <- data.frame(data=as.Date(storicoProvince$data), 200 | Provincia = storicoProvince$denominazione_provincia, 201 | Regione = storicoProvince$denominazione_regione, 202 | totale_casi = storicoProvince$totale_casi, 203 | x = (as.numeric(as.Date(storicoProvince$data)) - min(as.numeric(as.Date(storicoProvince$data))) + 1)) 204 | myProvince <- myProvince %>% 205 | group_by(Provincia) %>% 206 | mutate(diff_totale_casi = diff(c(0, totale_casi))) 207 | myProvince 208 | }) 209 | 210 | dataRegioniInput <- reactive({ 211 | storicoRegioni <- read.csv(file = "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-regioni/dpc-covid19-ita-regioni.csv", stringsAsFactors = FALSE) 212 | 213 | myRegioni <- data.frame(data=as.Date(storicoRegioni$data), 214 | Regione = storicoRegioni$denominazione_regione, 215 | totale_attualmente_positivi = storicoRegioni$totale_positivi, 216 | nuovi_attualmente_positivi = storicoRegioni$variazione_totale_positivi, 217 | deceduti = storicoRegioni$deceduti, 218 | dimessi_guariti = storicoRegioni$dimessi_guariti, 219 | totale_casi = storicoRegioni$totale_casi, 220 | ricoverati_con_sintomi = storicoRegioni$ricoverati_con_sintomi, 221 | terapia_intensiva = storicoRegioni$terapia_intensiva, 222 | isolamento_domiciliare = storicoRegioni$isolamento_domiciliare, 223 | tamponi = storicoRegioni$tamponi, 224 | x = (as.numeric(as.Date(storicoRegioni$data)) - min(as.numeric(as.Date(storicoRegioni$data))) + 1)) 225 | myRegioni <- myRegioni %>% 226 | group_by(Regione) %>% 227 | mutate(diff_deceduti = diff(c(0, deceduti)), 228 | diff_dimessi_guariti = diff(c(0, dimessi_guariti)), 229 | diff_ricoverati_con_sintomi = diff(c(0, ricoverati_con_sintomi)), 230 | diff_terapia_intensiva = diff(c(0, terapia_intensiva)), 231 | diff_isolamento_domiciliare = diff(c(0, isolamento_domiciliare)), 232 | diff_totale_casi = diff(c(0, totale_casi)), 233 | diff_tamponi = diff(c(0, tamponi)), 234 | totalratetamponi = round(totale_casi/tamponi, 4), 235 | dailyratetamponi = round(diff_totale_casi/diff_tamponi, 4)) 236 | myRegioni 237 | }) 238 | 239 | dataItaliaInput <- reactive({ 240 | storicoItalia <- read.csv(file = "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-andamento-nazionale/dpc-covid19-ita-andamento-nazionale.csv", stringsAsFactors = FALSE) 241 | 242 | myItalia <- data.frame(data=as.Date(storicoItalia$data), 243 | totale_attualmente_positivi = storicoItalia$totale_positivi, 244 | nuovi_attualmente_positivi = storicoItalia$variazione_totale_positivi, 245 | deceduti = storicoItalia$deceduti, 246 | diff_deceduti = diff(c(0, storicoItalia$deceduti)), 247 | dimessi_guariti = storicoItalia$dimessi_guariti, 248 | diff_dimessi_guariti = diff(c(0, storicoItalia$dimessi_guariti)), 249 | totale_casi = storicoItalia$totale_casi, 250 | diff_totale_casi = diff(c(0, storicoItalia$totale_casi)), 251 | ricoverati_con_sintomi = storicoItalia$ricoverati_con_sintomi, 252 | diff_ricoverati_con_sintomi = diff(c(0, storicoItalia$ricoverati_con_sintomi)), 253 | terapia_intensiva = storicoItalia$terapia_intensiva, 254 | diff_terapia_intensiva = diff(c(0, storicoItalia$terapia_intensiva)), 255 | isolamento_domiciliare = storicoItalia$isolamento_domiciliare, 256 | diff_isolamento_domiciliare = diff(c(0, storicoItalia$isolamento_domiciliare)), 257 | tamponi = storicoItalia$tamponi, 258 | diff_tamponi = diff(c(0, storicoItalia$tamponi)), 259 | casi_testati = storicoItalia$casi_testati, 260 | diff_casi_testati = diff(c(0,storicoItalia$casi_testati)), 261 | x = (as.numeric(as.Date(storicoItalia$data)) - min(as.numeric(as.Date(storicoItalia$data))) + 1)) 262 | myItalia 263 | }) 264 | 265 | output$selezionaGiornoRegio <- renderUI({ 266 | sliderTextInput( 267 | inputId = "selezionaGiornoRegio", 268 | label = "Select the day of interest", 269 | grid = FALSE, 270 | force_edges = TRUE, 271 | width = 500, 272 | selected = as.Date(dataRegioniInput()$data[length(dataRegioniInput()$data)]), 273 | choices = seq(as.Date("2020-02-24"), as.Date(dataRegioniInput()$data[length(dataRegioniInput()$data)]), 1) 274 | ) 275 | }) 276 | 277 | output$selezionaGiornoProv <- renderUI({ 278 | sliderTextInput( 279 | inputId = "selezionaGiornoProv", 280 | label = "Select the day of interest", 281 | grid = FALSE, 282 | force_edges = TRUE, 283 | width = 500, 284 | selected = as.Date(dataProvinceInput()$data[length(dataProvinceInput()$data)]), 285 | choices = seq(as.Date("2020-02-24"), as.Date(dataProvinceInput()$data[length(dataProvinceInput()$data)]), 1) 286 | ) 287 | }) 288 | 289 | output$headerCruscotto <- reactive({ 290 | ultimaData <- dataItaliaInput()$data[length(dataItaliaInput()$data)] 291 | paste0(h1("The current* situation of the CoVid-19 epidemic in Italy:"), h5("* (updated to the latest available data, dating back to 18pm on", day(ultimaData), "August 2020)")) 292 | }) 293 | 294 | output$summary <- reactive({ 295 | attualmente_positivi_ultimo <- dataItaliaInput()$totale_attualmente_positivi[length(dataItaliaInput()$totale_attualmente_positivi)] 296 | attualmente_positivi_penultimo <- dataItaliaInput()$totale_attualmente_positivi[length(dataItaliaInput()$totale_attualmente_positivi) - 1] 297 | delta_attualmente_positivi <- diff(c(attualmente_positivi_penultimo, attualmente_positivi_ultimo)) 298 | 299 | deceduti_ultimo <- dataItaliaInput()$deceduti[length(dataItaliaInput()$deceduti)] 300 | deceduti_penultimo <- dataItaliaInput()$deceduti[length(dataItaliaInput()$deceduti) - 1] 301 | delta_deceduti <- diff(c(deceduti_penultimo, deceduti_ultimo)) 302 | 303 | dimessi_guariti_ultimo <- dataItaliaInput()$dimessi_guariti[length(dataItaliaInput()$dimessi_guariti)] 304 | dimessi_guariti_penultimo <- dataItaliaInput()$dimessi_guariti[length(dataItaliaInput()$dimessi_guariti) - 1] 305 | delta_dimessi_guariti <- diff(c(dimessi_guariti_penultimo, dimessi_guariti_ultimo)) 306 | 307 | totale_casi_ultimo <- dataItaliaInput()$totale_casi[length(dataItaliaInput()$totale_casi)] 308 | totale_casi_penultimo <- dataItaliaInput()$totale_casi[length(dataItaliaInput()$totale_casi) - 1] 309 | delta_totale_casi <- diff(c(totale_casi_penultimo, totale_casi_ultimo)) 310 | 311 | casi_testati_ultimo <- dataItaliaInput()$casi_testati[length(dataItaliaInput()$casi_testati)] 312 | casi_testati_penultimo <- dataItaliaInput()$casi_testati[length(dataItaliaInput()$casi_testati) - 1] 313 | delta_casi_testati <- diff(c(casi_testati_penultimo, casi_testati_ultimo)) 314 | 315 | delta_dimessiguariti_attualmentepositivi <- diff(c(dimessi_guariti_penultimo/attualmente_positivi_penultimo, dimessi_guariti_ultimo/attualmente_positivi_ultimo)) 316 | paste0("