forked from epiforecasts/covidregionaldata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
153 lines (110 loc) · 6.71 KB
/
README.Rmd
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Subnational data for the COVID-19 outbreak
[](https://lifecycle.r-lib.org/articles/stages.html) [](https://github.com/epiforecasts/covidregionaldata/actions) [](https://codecov.io/gh/epiforecasts/covidregionaldata?branch=master) [](https://epiforecasts.io/covidregionaldata/articles/dataset-status.html) [](https://cran.r-project.org/package=covidregionaldata)
[](https://github.com/epiforecasts/covidregionaldata/blob/master/LICENSE.md/) [](https://github.com/epiforecasts/covidregionaldata/graphs/contributors) [](https://makeapullrequest.com/) [](https://github.com/epiforecasts/covidregionaldata/commit/master/) [](https://zenodo.org/badge/latestdoi/271601189) [](https://joss.theoj.org/papers/dd6f7acdae3b7136a3ac373ce9a0655c)
An interface to subnational and national level COVID-19 data. For all countries supported, this includes a daily time-series of cases. Wherever available we also provide data on deaths, hospitalisations, and tests. National level data is also supported using a range of data sources as well as line list data and links to intervention data sets. This package is designed for people who wan't access to standardised Covid-19 data from 'official' sources.
## Installation
Install from CRAN:
```{r, eval = FALSE}
install.packages("covidregionaldata")
```
Install the stable development version of the package with:
```{r, eval = FALSE}
install.packages("drat")
drat:::add("epiforecasts")
install.packages("covidregionaldata")
```
Install the unstable development version of the package with:
```{r, eval = FALSE}
remotes::install_github("epiforecasts/covidregionaldata")
```
## Quick start
[](https://epiforecasts.io/covidregionaldata/)
Load `covidregionaldata`, `dplyr`, `scales`, and `ggplot2` (all used in this quick start),
```{r, message = FALSE}
library(covidregionaldata)
library(dplyr)
library(ggplot2)
library(scales)
```
### Setup data caching
This package can optionally use a data cache from `memoise` to locally cache downloads. This can be enabled using the following (this will use the temporary directory by default),
```{r}
start_using_memoise()
```
To stop using `memoise` use,
```{r, eval = FALSE}
stop_using_memoise()
```
and to reset the cache (required to download new data),
```{r, eval = FALSE}
reset_cache()
```
### National data
To get worldwide time-series data by country (sourced from the World Health Organisation (WHO) by default by also optionally from the European Centre for Disease Control (ECDC), John Hopkins University, or the Google COVID-19 open data project), use:
```{r}
nots <- get_national_data()
nots
```
This can also be filtered for a country of interest,
```{r}
g7 <- c(
"United States", "United Kingdom", "France", "Germany",
"Italy", "Canada", "Japan"
)
g7_nots <- get_national_data(countries = g7, verbose = FALSE)
```
Using this data we can compare case information between countries, for example here is the number of deaths over time for each country in the G7:
```{r g7_plot, warning = FALSE, message = FALSE}
g7_nots %>%
ggplot() +
aes(x = date, y = deaths_new, col = country) +
geom_line(alpha = 0.4) +
labs(x = "Date", y = "Reported Covid-19 deaths") +
scale_y_continuous(labels = comma) +
theme_minimal() +
theme(legend.position = "top") +
guides(col = guide_legend(title = "Country"))
```
### Subnational data
To get time-series data for subnational regions of a specific country, for example by level 1 region in the UK, use:
```{r}
uk_nots <- get_regional_data(country = "UK", verbose = FALSE)
uk_nots
```
Now we have the data we can create plots, for example the time-series of the number of cases for each region:
```{r uk_plot, warning = FALSE, message = FALSE}
uk_nots %>%
filter(!(region %in% "England")) %>%
ggplot() +
aes(x = date, y = cases_new, col = region) +
geom_line(alpha = 0.4) +
labs(x = "Date", y = "Reported Covid-19 cases") +
scale_y_continuous(labels = comma) +
theme_minimal() +
theme(legend.position = "top") +
guides(col = guide_legend(title = "Region"))
```
See `get_available_datasets()` for supported regions and subregional levels.
For an updated view of dataset status check the
[hosted page](https://epiforecasts.io/covidregionaldata/articles/dataset-status.html)
or build the [dataset status vignette](vignettes/dataset-status.Rmd).
For further examples see the [quick start vignette](https://github.com/epiforecasts/covidregionaldata/blob/master/vignettes/quickstart.Rmd). Additional subnational data are supported via the `JHU()` and `Google()` classes. Use the `available_regions()` method once these data have been downloaded and cleaned (see their examples) for subnational data they internally support.
## Citation
If using `covidregionaldata` in your work please consider citing it using the following,
```{r, echo = FALSE}
citation("covidregionaldata")
```
## Development
[](https://github.com/epiforecasts/covidregionaldata/wiki/)
We welcome contributions and new contributors! We particularly appreciate help adding new data sources for countries at sub-national level, or work on priority problems in the [issues](https://github.com/epiforecasts/covidregionaldata/issues). Please check and add to the issues, and/or add a [pull request](https://github.com/epiforecasts/covidregionaldata/pulls). For more details, start with the [contributing guide](https://github.com/epiforecasts/covidregionaldata/wiki/Contributing). For details of the steps required to add support for a dataset see the [adding data guide](https://github.com/epiforecasts/covidregionaldata/wiki/Adding-Data).