-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcountry_report.Rmd
118 lines (86 loc) · 5.19 KB
/
country_report.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
---
title: "Cases and deaths from JHU and MPIDR datasets"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message=FALSE, fig.width=8, fig.height=6)
```
```{r}
iso0 = "USA"
suppressPackageStartupMessages({
library("data.table")
library("ggplot2")
library("readr")
library("cowplot")
library("osfr")
library("kableExtra")
library("plotly")
})
invisible(lapply(list.files(here::here("R"), full.names = TRUE), source))
# download input.DB as zip file and read in
# `load_fresh` will save a local copy
dt5_ori <- load_fresh(backup = TRUE)
dt5_ori <- fread(here::here("data_backup/dt5_ori.csv"))
dt5 <- clean_outputDB(dt5_ori)
countries_w_new_update <- dt5[Date>"2020-10-01", unique(Country)]
all_countries <- get_cnames(dt5) # all countries in the datasets
# range of `max_date`
dt_date <- unique(dt5[,.(Country, max_date)])
#
# country-specific JHU time series
dtJHU_country <- get.JHU.ts()
dtJHU_country <- process_dtJHU(dtJHU_country)
p1_JHU_P <- plot_country_JHU(dtJHU =dtJHU_country, iso3 = iso0)
#
# summary tables
dtJHU <- get.JHU.daily()
dtJHU2 <- process_dtJHU(dtJHU)
all_countries <- get_cnames(dt5) # all countries
dt5_country <- get_dt5_pool_sex(dt5) # dt5_country has all the countries, pooled sex into total and remove NA value
dt5_country <- join_region(dt5_country) # joined to region
# dt5_summary_simple <- get_summary_table(dt5_country)
dt5_summary <- get_summary_table_region2(dt5_country, dtJHU2, combine_sex = FALSE)
dtt <- dt5_summary[ISO3Code == iso0]
if(nrow(dtt)==0) stop("Is the country name correct, use official country name.")
# show:
dtt[, Pcnt0_19 := round(Pcnt0_19*100, 1)]
setnames(dtt, "MPIDR_JHU", "COVerAGE-DB/JHU(%)")
dtt[Measure == "Cases", `Age 0-19` := paste0(prettyNum(Sum0_19, big.mark = ","),
" (", round(Pcnt0_19), "%)")] # round to .
dtt[Measure == "Deaths", `Age 0-19` := paste0(prettyNum(Sum0_19, big.mark = ","),
" (", Pcnt0_19, "%)")]
dt1_total <- dtt[Sex=="Both"][,.(Country, Measure,JHU, `COVerAGE-DB/JHU(%)`, `Age 0-4`, `Age 5-9`, `Age 10-14`,
`Age 15-19`, `Age 0-19`)]
dt2_by_sex <- dtt[Sex!="Both"][,.(Country, Measure, Sex, `COVerAGE-DB/JHU(%)`, `Age 0-4`, `Age 5-9`, `Age 10-14`,
`Age 15-19`, `Age 0-19`)]
# country-specific age-pyramid ----
dt5_country[,AgeInt:=5]
p2_P <- make_country_plot(iso3 = iso0, dt1 = dt5_country)
cname0 <- dt5_country[ISO3Code == iso0, Country[1]]
```
## Source of data
Johns Hopkins University (JHU) data refer to the daily-updated data used for their dashboard. The dataset was downloaded from the [project page](https://github.com/CSSEGISandData/COVID-19).
COVerAGE-DB, led by the Max Planck Institute, is an open-access database including cumulative counts of confirmed COVID-19 cases, deaths, and tests by age and sex. Original data and sources are provided alongside data and measures in standardized and age-harmonized formats. The data were extracted from reports published by official governmental institutions in a variety of formats. The [project page](https://github.com/timriffe/covid_age) and the [medRxiv paper](https://www.medrxiv.org/content/10.1101/2020.09.18.20197228v2) contain the technical details. The database is still in development. On `r Sys.Date()` it includes `r dt5_ori[, uniqueN(Country)]` countries and `r dt5_ori[Region!="All", uniqueN(Region)]` subnational areas.
## `r cname0`
### Data from Johns Hopkins University
**Last updated on `r dtJHU2[ISO3Code == iso0, Last_Update][1]`**
Figure 1. Daily cases and deaths from Johns Hopkins University
```{r, fig.width = 8, fig.height = 6}
plotly::ggplotly(p1_JHU_P)
```
### Data from COVerAGE-DB
**The COVerAGE-DB dataset for `r cname0` was most recently updated on `r dt5_country[ISO3Code == iso0, max_date][1]`**
Table 1.a. The cases and deaths reported by Johns Hopkins University (JHU) and extracted from the COVerAGE-DB database. The fourth column (COVerAGE-DB/JHU) shows the ratio of case and death counts from COVerAGE-DB to those reported by JHU. The harmonized data of age groups 0-4, 5-9, 10-14, 15-19 are listed in the table. Their counts sum to age group 0-19 and the percentage values show this age group's proportion in all age groups.
```{r}
print_table_pdf(dt1_total)
```
Table 1.b. Counts of COVID-19 cases and deaths by sex from COVerAGE-DB. The harmonized data for age groups 0-4, 5-9, 10-14, 15-19 and 0-19 as well as the proportion of age group 0-19 are shown in the table.
```{r}
print_table_pdf(dt2_by_sex)
```
Figure 2. Age distribution of COVID-19 cases, deaths and case fatality rate (CFR), with 5-year age interval. CFR is calculated by dividing death counts by case counts for each age group.
```{r, fig.width=14, fig.height=6}
p2_P
```
## Reference
Dong E, Du H, Gardner L. An interactive web-based dashboard to track COVID-19 in real time. Lancet Inf Dis. 20(5):533-534. [https://doi.org/10.1016/S1473-3099(20)30120-1](https://doi.org/10.1016/S1473-3099(20)30120-1){.uri}
Riffe, T., Acosta, E., and The COVerAGE-DB team (2020). COVerAGE-DB: A database of COVID-19 cases and deaths by age. medRxiv <https://doi.org/10.1101/2020.09.18.20197228>