Skip to content

Commit

Permalink
Merge pull request #9 from b-kennedy0:b-kennedy0/issue8
Browse files Browse the repository at this point in the history
Broken chart - 2nd dose figures
  • Loading branch information
b-kennedy0 authored May 17, 2021
2 parents 61b173e + 7a73b25 commit e5d2ff6
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 8 deletions.
76 changes: 75 additions & 1 deletion server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ",")
Expand All @@ -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({
Expand Down Expand Up @@ -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({
Expand Down
60 changes: 60 additions & 0 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
75 changes: 68 additions & 7 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h3>Navigation</h3>
<ul class="header-nav__list">
<li class="current"><a class="smoothscroll" href="#home" title="Home Page">Home</a></li>
<li><a class="smoothscroll" href="#stats" title="Vaccination Data">Vaccination Data</a></li>
<li><a class="smoothscroll" href="#per_week" title="Chart of Vaccines per week">Vaccinations per week</a></li>
<!-- <li><a class="smoothscroll" href="#per_week" title="Chart of Vaccines per week">Vaccinations per week</a></li> -->
<li><a class="smoothscroll" href="#about" title="About the App">About the App</a></li>
</ul>
<p>Version: {{version}}<br><a href="https://coronavirus.data.gov.uk/" target="_blank">View data source.</a><br><a href="https://github.com/b-kennedy0/COVID19-Vaccine-App" target="_blank">View App Code.</a><br><br>If you have a suggestions or notice an issue, please report using the link in the <a href="#footer" class="scroll-link smoothscroll">footer</a>.<br><br>Created, hosted and maintained by <a href="https://bradleykennedy.co.uk" target="_blank">Brad Kennedy</a>.<br>If you enjoy using this app, please consider <a href="https://monzo.me/bradleykennedy5/5.00?d=COVID-19%20Vaccine%20App" target="_blank">supporting me.</a> Thank you!</p>
Expand Down Expand Up @@ -180,6 +180,58 @@ <h6>{{ni_vaccines_no}} Vaccines</h6>

<!--- END NUMBERS BY INTEGRATING SHINY OUTPUT -->


<div class="row section-header has-bottom-sep" data-aos="fade-up">
<div class="col-full">
<h3 class="subhead subhead--dark">2nd Dose Vaccination Data</h3>
<h1 class="display-1 display-1--light">
Total so far in the UK: {{total_no_vaccines_uk_2ndDose}} ({{total_perc_vaccines_uk_2ndDose}}%)
</h1>
</div>
</div> <!-- end section-header -->

<!-- end stats-desc -->

<!--- NUMBERS BY INTEGRATING SHINY OUTPUT -->
<div class="row about-stats stats block-1-4 block-m-1-2 block-mob-full" data-aos="fade-up">

<div class="col-block stats__col">
<h6>England</h6>
<div class="stats__count">
{{eng_vaccines_pc_2ndDose}}
</div>
<h5>% of the adult population</h5>
<h6>{{eng_vaccines_no_2ndDose}} Vaccines</h6>
</div>
<div class="col-block stats__col">
<h6>Wales</h6>
<div class="stats__count">
{{wal_vaccines_pc_2ndDose}}
</div>
<h5>% of the adult population</h5>
<h6>{{wal_vaccines_no_2ndDose}} Vaccines</h6>
</div>
<div class="col-block stats__col">
<h6>Scotland</h6>
<div class="stats__count">
{{sco_vaccines_pc_2ndDose}}
</div>
<h5>% of the adult population</h5>
<h6>{{sco_vaccines_no_2ndDose}} Vaccines</h6>
</div>
<div class="col-block stats__col">
<h6>Northern Ireland</h6>
<div class="stats__count">
{{ni_vaccines_pc_2ndDose}}
</div>
<h5>% of the adult population</h5>
<h6>{{ni_vaccines_no_2ndDose}} Vaccines</h6>
</div>

</div>

<!--- END NUMBERS BY INTEGRATING SHINY OUTPUT -->

<div class="row section-header">
<div class="col-full">
<h4 class="subhead subhead--dark">Data up to: {{latest_date}}</h4>
Expand All @@ -200,8 +252,9 @@ <h4 class="subhead subhead--dark">Retrieved on: <span id="date"></span><script>v
</section>
<!-- end s-stats -->

<!-- per week data
<!-- per week data BROKEN NOW REMOVED
================================================== -->
<!--
<section id='per_week' class="s-works">
<div class="intro-wrap">
Expand All @@ -211,10 +264,14 @@ <h4 class="subhead subhead--dark">Retrieved on: <span id="date"></span><script>v
<h3 class="subhead">Vaccines per week</h3>
<h1 class="display-2 display-2--light">View how many vaccines are being given per week</h1>
<h4 class="subhead"><em>Tap/Click on the Nations to show/hide them</em></h4>
</div><!-- end col-full -->
</div> <!-- end section-header -->
{{plot}}
</div> <!-- end intro-wrap -->
</div>
-->
<!-- end col-full -->
<!-- </div> -->
<!-- end section-header -->

<!-- </div> -->
<!-- end intro-wrap -->

<!-- <div class="row services-list block-1-2 block-tab-full">
<div class="col-block service-item aos-init aos-animate" data-aos="fade-up">
Expand All @@ -224,7 +281,11 @@ <h4 class="subhead"><em>Tap/Click on the Nations to show/hide them</em></h4>
This is some test content - the controls might be here.
</div>
</div> -->
</section> <!-- end s-works -->
<!--
</section>
-->
<!-- end s-works -->


<!-- about ================================================== -->
<section id='about' class="s-clients">
Expand Down

0 comments on commit e5d2ff6

Please sign in to comment.