In this tutorial, you will learn
Data links:
To load in the data, we can read it directly from the URLs above.
We’ll also need the tidyverse
and
lubridate
:
Convert the long case_data
data frame into a table
with three columns:
date
: The date of diagnosislocal_government_area
: The LGA of interestnum_cases
: The number of PCR positive cases on a given
day.Draw a plot with the total number of cases on the y
axis, and the LGAs (ordered from least to most cases) on the x
axis.
You can add
theme(axis.text.x = element_text(angle = 90, hjust=1, vjust=0.5))
to your ggplot
to rotate and align the text.
Convert the dose numbers for vaccination to numeric variables
instead of characters. For LGAs with >95% coverage, set them to
0.95.
(hint: substr(x, 1, nchar(x)-1)
will remove the last
character of a string)
Draw a plot with the third dose coverage on the y axis, and LGAs (ordered from lowest to highest coverage) on the x axis.
The growth rate over a time period, \(t_1\), is defined as
\[C(t_1) = C(t_0) \exp(rt),\] where \(r\) is the rate of growth.
Rearranging this expression gives, \[r = \frac{\log\left(\frac{C(t_1)}{C(t_0)}\right)}{t}.\]
Below is a function called calculate_growth_rate
that
takes three inputs (Ct0
, Ct1
, and
time
) and returns the growth rate.
Remember, it’s always a good idea to test your code and make sure it
returns the numbers you expect.
calculate_growth_rate <- function(Ct0, Ct1, time) {
log(Ct1 / Ct0) / time
}
You’ve been asked to explore whether vaccination coverage and growth rate are correlated. You are on a tight deadline and so only have time to produce one plot.
Thankfully, your colleague has given you some code to join together the vaccination coverage and growth rate data:
codes_to_remove <- c(
" \\(C\\)",
" \\(S\\)",
" \\(RC\\)",
" \\(B\\)"
) %>%
paste0(collapse = "|")
summarised_growths <- summarised_growths %>%
mutate(local_government_area = gsub(
pattern = codes_to_remove,
replacement = "",
x = local_government_area
))
terminal_coverage <- vaccination_data_converted %>%
left_join(summarised_growths, on = "local_government_area")
Create a plot that shows evidence for or against the hypothesis that vaccination coverage and growth rate are correlated. Write a maximum four sentence executive summary of your findings, and compare with a partner in the class.