-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcovid-analysis.qmd
52 lines (42 loc) · 1.26 KB
/
covid-analysis.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
title: "Covid data from {NHSRdatasets}"
format: html
params:
country: "New_Zealand"
month_start: "2019-12-01"
month_end: "2020-12-01"
---
```{r}
#| label: packages
#| eval: true
#| include: false
library(tidyverse)
library(NHSRdatasets)
# Note to get the covid19 data the installation needs to be from GitHub not CRAN
# install.packages("remotes")
# remotes::install_github("nhs-r-community/NHSRdatasets")
```
```{r}
total_records <- NHSRdatasets::covid19 |>
filter(countries_and_territories == params$country) |>
summarise(total = n())
```
# Country analysis
## Overview
There are `r total_records` records for `r params$country %>% stringr::str_replace("_", " ")` for the period `r format(lubridate::as_datetime(params$month_start), '%d %B %Y')` to `r format(lubridate::as_datetime(params$month_end), '%d %B %Y')`.
## Covid cases
```{r}
data <- NHSRdatasets::covid19 |>
mutate(month = lubridate::floor_date(date_reported, unit = "month")) |>
filter(countries_and_territories == params$country,
month >= params$month_start & month <= params$month_end)
ggplot(data, aes(x = date_reported,
y = cases)) +
geom_point() +
geom_line() +
labs(
x = "Date reported",
y = "Covid reported cases"
) +
expand_limits(y = 0)
```