From 7a73b251c260321a585c1b6210a63efac88d977f Mon Sep 17 00:00:00 2001 From: b-kennedy0 Date: Mon, 17 May 2021 12:50:48 +0100 Subject: [PATCH] Broken chart - 2nd dose figures Fixes #8 --- server.R | 76 +++++++++++++++++++++++++++++++++++++++++++++++++- ui.R | 60 +++++++++++++++++++++++++++++++++++++++ www/index.html | 75 ++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 203 insertions(+), 8 deletions(-) diff --git a/server.R b/server.R index 1ee5bf0..8b0d476 100644 --- a/server.R +++ b/server.R @@ -14,6 +14,8 @@ server <- function(input, output) { uk_pop <- sum(eng_pop,wal_pop,sco_pop,ni_pop) uk_total <- sum(dataset$cumPeopleVaccinatedFirstDoseByPublishDate [dataset$date==max(dataset$date)]) + uk_total2 <- sum(dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date)]) # Population data formatted for use in index ----------------------------- output$england <- renderText({ format(as.numeric(eng_pop), big.mark = ",") @@ -28,7 +30,7 @@ server <- function(input, output) { format(as.numeric(ni_pop), big.mark = ",") }) - # Formatting vaccine data (% and No) for use in index ---------------------- + # Formatting vaccine data (% and No) for use in index 1st DOSE ---------------------- # Total % UK Vaccines output$total_uk_perc <- renderText({ @@ -100,6 +102,78 @@ server <- function(input, output) { & dataset$areaName=="Northern Ireland"]), big.mark = ",") }) + # Formatting vaccine data (% and No) for use in index 2nd DOSE ---------------------- + + # Total % UK Vaccines 2ndDose + output$total_uk_perc_2ndDose <- renderText({ + format(round(as.numeric((uk_total2 / uk_pop) * 100), digits = 2), nsmall = 2) + }) + + # Total no UK Vaccines 2ndDose + output$total_uk_no_2ndDose <- renderText({ + format(as.numeric(uk_total2), big.mark = ",") + }) + + # England % 2ndDose + output$eng_2ndDose <- renderText({ + format(round(as.numeric((dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="England"] / eng_pop) * 100), + digits = 2), nsmall = 2) + }) + + # Wales % 2ndDose + output$wal_2ndDose <- renderText({ + format(round(as.numeric((dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="Wales"] / wal_pop) * 100), + digits = 2), nsmall = 2) + }) + + # Scotland % 2ndDose + output$sco_2ndDose <- renderText({ + format(round(as.numeric((dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="Scotland"] / sco_pop) * 100), + digits = 2), nsmall = 2) + }) + + # NI % 2ndDose + output$ni_2ndDose <- renderText({ + format(round(as.numeric((dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="Northern Ireland"] / ni_pop) * 100), + digits = 2), nsmall = 2) + }) + + # England No 2ndDose + output$eng_no_2ndDose <- renderText({ + format(as.numeric(dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="England"]), big.mark = ",") + }) + + # Wales No 2ndDose + output$wal_no_2ndDose <- renderText({ + format(as.numeric(dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="Wales"]), big.mark = ",") + }) + + # Scotland No 2ndDose + output$sco_no_2ndDose <- renderText({ + format(as.numeric(dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="Scotland"]), big.mark = ",") + }) + + # NI No 2ndDose + output$ni_no_2ndDose <- renderText({ + format(as.numeric(dataset$cumPeopleVaccinatedSecondDoseByPublishDate + [dataset$date==max(dataset$date) + & dataset$areaName=="Northern Ireland"]), big.mark = ",") + }) + # Vaccinations per day plot -------------------------------------------- output$plot <- renderPlotly({ diff --git a/ui.R b/ui.R index b46d295..5f52316 100644 --- a/ui.R +++ b/ui.R @@ -85,6 +85,66 @@ ui = shiny::htmlTemplate( inline = T ), + # 2nd Dose + + total_perc_vaccines_uk_2ndDose = textOutput( + "total_uk_perc_2ndDose", + inline = T + ), + + total_no_vaccines_uk_2ndDose = textOutput( + "total_uk_no_2ndDose", + inline = T + ), + + # England % + eng_vaccines_pc_2ndDose = textOutput( + "eng_2ndDose", + inline = T + ), + + # Wales % + wal_vaccines_pc_2ndDose = textOutput( + "wal_2ndDose", + inline = T + ), + + # Scotland % + sco_vaccines_pc_2ndDose = textOutput( + "sco_2ndDose", + inline = T + ), + + # NI % + ni_vaccines_pc_2ndDose = textOutput( + "ni_2ndDose", + inline = T + ), + + # Englnad No + eng_vaccines_no_2ndDose = textOutput( + "eng_no_2ndDose", + inline = T + ), + + # Wales No + wal_vaccines_no_2ndDose = textOutput( + "wal_no_2ndDose", + inline = T + ), + + # Scotland No + sco_vaccines_no_2ndDose = textOutput( + "sco_no_2ndDose", + inline = T + ), + + # NI No + ni_vaccines_no_2ndDose = textOutput( + "ni_no_2ndDose", + inline = T + ), + # Plot plot = plotlyOutput({ "plot" diff --git a/www/index.html b/www/index.html index f732cb5..8a6b27c 100644 --- a/www/index.html +++ b/www/index.html @@ -64,7 +64,7 @@

Navigation

Version: {{version}}
View data source.
View App Code.

If you have a suggestions or notice an issue, please report using the link in the footer.

Created, hosted and maintained by Brad Kennedy.
If you enjoy using this app, please consider supporting me. Thank you!

@@ -180,6 +180,58 @@
{{ni_vaccines_no}} Vaccines
+ +
+
+

2nd Dose Vaccination Data

+

+ Total so far in the UK: {{total_no_vaccines_uk_2ndDose}} ({{total_perc_vaccines_uk_2ndDose}}%) +

+
+
+ + + + +
+ +
+
England
+
+ {{eng_vaccines_pc_2ndDose}} +
+
% of the adult population
+
{{eng_vaccines_no_2ndDose}} Vaccines
+
+
+
Wales
+
+ {{wal_vaccines_pc_2ndDose}} +
+
% of the adult population
+
{{wal_vaccines_no_2ndDose}} Vaccines
+
+
+
Scotland
+
+ {{sco_vaccines_pc_2ndDose}} +
+
% of the adult population
+
{{sco_vaccines_no_2ndDose}} Vaccines
+
+
+
Northern Ireland
+
+ {{ni_vaccines_pc_2ndDose}} +
+
% of the adult population
+
{{ni_vaccines_no_2ndDose}} Vaccines
+
+ +
+ + +

Data up to: {{latest_date}}

@@ -200,8 +252,9 @@

Retrieved on: