🎯 Objectives

In this tutorial, you will learn

🔧 Preparation

Data links:

To load in the data, we can read it directly from the URLs above.

We’ll also need the tidyverse and lubridate:

⚙️ Tutorial

1. Manipulating the data

  1. Convert the long case_data data frame into a table with three columns:

    1. date: The date of diagnosis
    2. local_government_area: The LGA of interest
    3. num_cases: The number of PCR positive cases on a given day.
  2. 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.

  3. 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)

  4. Draw a plot with the third dose coverage on the y axis, and LGAs (ordered from lowest to highest coverage) on the x axis.

2. Calculating the growth rate

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
}
  1. Calculate the 7-day growth rate for each Victorian LGA since 1 January 2022. For this tutorial, we will assume detection date (which is what is present in the data) is the infection date to calculate the growth rate on.

3. Correlating growth rates with vaccination coverage

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.