library (readr)
library(knitr)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ dplyr 1.0.10
## ✔ tibble 3.1.8 ✔ stringr 1.4.1
## ✔ tidyr 1.2.1 ✔ forcats 0.5.2
## ✔ purrr 0.3.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library (ggplot2)
library(dplyr)
library(hrbrthemes)
## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
## Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
## if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
healthcare <- read.csv("Downloads/phe_healthcare.csv")
healthcare2 <- head(healthcare, 25)
options(knitr.kable.NA = "**")
knitr::kable(NA)
x |
---|
** |
result = FALSE
knitr::kable(healthcare2, align = "lccrr")
date | area_name | healthcare_type | patients |
---|---|---|---|
2020-03-19 | London | Patients in mechanical ventilation beds | ** |
2020-03-19 | London | Patients in Hospital | ** |
2020-03-19 | London | Patients admitted to Hospital | 240 |
2020-03-19 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-19 | Rest of England | Patients in Hospital | ** |
2020-03-19 | Rest of England | Patients admitted to Hospital | 346 |
2020-03-20 | London | Patients in mechanical ventilation beds | ** |
2020-03-20 | London | Patients in Hospital | 841 |
2020-03-20 | London | Patients admitted to Hospital | 272 |
2020-03-20 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-20 | Rest of England | Patients in Hospital | 739 |
2020-03-20 | Rest of England | Patients admitted to Hospital | 419 |
2020-03-21 | London | Patients in mechanical ventilation beds | ** |
2020-03-21 | London | Patients in Hospital | 1081 |
2020-03-21 | London | Patients admitted to Hospital | 311 |
2020-03-21 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-21 | Rest of England | Patients in Hospital | 1071 |
2020-03-21 | Rest of England | Patients admitted to Hospital | 466 |
2020-03-22 | London | Patients in mechanical ventilation beds | ** |
2020-03-22 | London | Patients in Hospital | 1266 |
2020-03-22 | London | Patients admitted to Hospital | 335 |
2020-03-22 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-22 | Rest of England | Patients in Hospital | 1404 |
2020-03-22 | Rest of England | Patients admitted to Hospital | 524 |
2020-03-23 | London | Patients in mechanical ventilation beds | ** |
This data set is located on the government website, London.gov.uk, and provides the user with count of patients with Covid-19, and is categorized by “healthcare type”, “currently hospitalized”, “on a ventilator”, or “admitted to hospital”. The data is also available by date, and filtered by location. Please see the link below for the full data set.
healthcare2 %>%
kable(booktabs = TRUE, col.names = c("Date", "Area Name","Healthcare Type","Patients"),caption = "Datatable for London Covid Cases - https://data.london.gov.uk/dataset/coronavirus--covid-19--cases")
Date | Area Name | Healthcare Type | Patients |
---|---|---|---|
2020-03-19 | London | Patients in mechanical ventilation beds | ** |
2020-03-19 | London | Patients in Hospital | ** |
2020-03-19 | London | Patients admitted to Hospital | 240 |
2020-03-19 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-19 | Rest of England | Patients in Hospital | ** |
2020-03-19 | Rest of England | Patients admitted to Hospital | 346 |
2020-03-20 | London | Patients in mechanical ventilation beds | ** |
2020-03-20 | London | Patients in Hospital | 841 |
2020-03-20 | London | Patients admitted to Hospital | 272 |
2020-03-20 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-20 | Rest of England | Patients in Hospital | 739 |
2020-03-20 | Rest of England | Patients admitted to Hospital | 419 |
2020-03-21 | London | Patients in mechanical ventilation beds | ** |
2020-03-21 | London | Patients in Hospital | 1081 |
2020-03-21 | London | Patients admitted to Hospital | 311 |
2020-03-21 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-21 | Rest of England | Patients in Hospital | 1071 |
2020-03-21 | Rest of England | Patients admitted to Hospital | 466 |
2020-03-22 | London | Patients in mechanical ventilation beds | ** |
2020-03-22 | London | Patients in Hospital | 1266 |
2020-03-22 | London | Patients admitted to Hospital | 335 |
2020-03-22 | Rest of England | Patients in mechanical ventilation beds | ** |
2020-03-22 | Rest of England | Patients in Hospital | 1404 |
2020-03-22 | Rest of England | Patients admitted to Hospital | 524 |
2020-03-23 | London | Patients in mechanical ventilation beds | ** |
healthcare3 <- head(healthcare, 35)
p <- healthcare %>%
ggplot( aes(x=date, y=patients,fill = area_name)) + labs(title = "Interactive Graph For Patients By Area") +
geom_area(fill="#69b3a2",alpha=0.5) +
geom_line(color="#69b3a2") +
ylab("patients") +
theme_ipsum()
ggplotly(p)
## Warning: Removed 34 rows containing missing values (position_stack).
p <- healthcare3 %>%
ggplot( aes(x=date, y=patients,fill = area_name)) + labs(title = "'Zoomed In' Patients By Area") +
geom_area(fill="#69b3a2",alpha=0.5) +
geom_line(color="#69b3a2") +
ylab("patients") +
theme_ipsum()
ggplotly(p)
## Warning: Removed 14 rows containing missing values (position_stack).
data <- ggplot(healthcare3,aes(x = date, y = patients, fill=area_name)) + labs(title = "Total Cases By Day") + geom_bar(stat = "identity", position = "dodge")
data
## Warning: Removed 14 rows containing missing values (geom_bar).
Its interesting to view the historical data during a time in which was unpredictable. As stated previously, within a matter of days, March 20th to 24th, cases have doubled, admitting more individuals in the hospital. Looking back on this sort of data, allows for an analyst to describe the events, given variables in the environment, which also allows for security and risk-protection measures for a potential event like this in the future. This of course may be for the sake of financials or health. Not one individual could predict the extent in which the pandemic affected many people, and the tolls it took on our economy. Having reliable and readily data and visualizations, will allow a decision maker to spot trends and hopefully prevent as much as possible in the next event.
The difficulties were limited when preparing the data. The author has done a fantastic job at classifying patient according to regions, and a specific healthcare type. The graph that allows you to interact by zooming in and out was sort of difficult, because it requires a new library and an unfamiliar set of tools to construct the graph.