Commit 76bb83ab authored by Facundo Muñoz's avatar Facundo Muñoz ®️
Browse files

Target xeurope_countries: tibble with country names and group from extended europe.

Rather than 5 variables with names of countries for different groups.
parent 5d5948d6
Pipeline #16551 passed with stage
in 3 minutes and 6 seconds
...@@ -91,7 +91,7 @@ loadd( ...@@ -91,7 +91,7 @@ loadd(
world_map, world_map,
geo_europe_light, geo_europe_light,
roi_europe_light, roi_europe_light,
europe, eu28, efta, candi, noneu, xeurope_countries,
sdt, sdt,
wgs84, wgs84,
merc, merc,
...@@ -107,8 +107,8 @@ loadd( ...@@ -107,8 +107,8 @@ loadd(
## lockdown ## lockdown
Lock <- do.call( Lock <- do.call(
"rbind", "rbind",
by(subset(lock, name %in% europe), by(subset(lock, name %in% xeurope_countries$name),
list(name = subset(lock, name %in% europe)$name), list(name = subset(lock, name %in% xeurope_countries$name)$name),
function(x){ function(x){
smax <- max(x$stringency, na.rm = T) smax <- max(x$stringency, na.rm = T)
x$T90 <- min(x$date[x$stringency >= .9 * smax], na.rm = T) x$T90 <- min(x$date[x$stringency >= .9 * smax], na.rm = T)
...@@ -133,13 +133,7 @@ covid$name <- standardise_country_names(covid$name) ...@@ -133,13 +133,7 @@ covid$name <- standardise_country_names(covid$name)
## group, name, lockdown date, population, cumulated deaths, ## group, name, lockdown date, population, cumulated deaths,
## and death rate. ## and death rate.
country_data <- country_data <-
map_dfr( xeurope_countries %>%
list("europe"),
~tibble(
group = .,
name = get(.)
)
) %>%
## filter(name != "Liechtenstein") %>% ## filter(name != "Liechtenstein") %>%
left_join( left_join(
lockdown_dates, lockdown_dates,
...@@ -364,7 +358,7 @@ sharing similar mortality patterns. ...@@ -364,7 +358,7 @@ sharing similar mortality patterns.
## Main results {-} ## Main results {-}
As per `r data_update_date`, in the `r length(europe)` countries As per `r data_update_date`, in the `r length(xeurope_countries$name)` countries
accounted for, the total number of deaths is `r sttnd` for an overall accounted for, the total number of deaths is `r sttnd` for an overall
population size of `r round(ttpop/1e6)` millions representing a population size of `r round(ttpop/1e6)` millions representing a
cumulative death rate of `r sttcdr` deaths $10^{-5}$ inhabitants. cumulative death rate of `r sttcdr` deaths $10^{-5}$ inhabitants.
...@@ -422,14 +416,14 @@ implementation. ...@@ -422,14 +416,14 @@ implementation.
The geographical scope of the study is: The geographical scope of the study is:
* the European Union and the UK (28 countries): `r collapse(eu28, cnt = NA)`, * the European Union and the UK (28 countries): `r collapse(xeurope_countries %>% filter(group == "EU28") %>% pull(name), cnt = NA)`,
* plus member countries of the European Free Trade Association (EFTA): * plus member countries of the European Free Trade Association (EFTA):
`r collapse(efta, cnt = NA)`; `r collapse(xeurope_countries %>% filter(group == "EFTA") %>% pull(name), cnt = NA)`;
* plus candidate countries for EU membership: `r collapse(candi, cnt = NA)`; * plus candidate countries for EU membership: `r collapse(xeurope_countries %>% filter(group == "Candidates") %>% pull(name), cnt = NA)`;
* plus European, non-EU countries: `r collapse(noneu, cnt = NA)`. * plus European, non-EU countries: `r collapse(xeurope_countries %>% filter(group == "Non_EU") %>% pull(name), cnt = NA)`.
Liechtenstein was excluded from the study because of its small population size. Liechtenstein was excluded from the study because of its small population size.
...@@ -446,7 +440,7 @@ Liechtenstein was excluded from the study because of its small population size. ...@@ -446,7 +440,7 @@ Liechtenstein was excluded from the study because of its small population size.
## Cumulative death rate ## Cumulative death rate
In the `r length(europe)` countries accounted for^[List (number of deaths in braces): `r collapse(nam = levels(Dfr$name), cnt = sond)`.], In the `r nrow(xeurope_countries)` countries accounted for^[List (number of deaths in braces): `r collapse(nam = levels(Dfr$name), cnt = sond)`.],
the total reported deaths is now `r sttnd` for an overall population size of the total reported deaths is now `r sttnd` for an overall population size of
`r round(sum(country_data$pop)/1e3,0)` millions, thus representing a cumulative death rate of `r round(sum(country_data$pop)/1e3,0)` millions, thus representing a cumulative death rate of
`r round(100 * sum(Dfr$deaths) / sum(country_data$pop), 1)` deaths $10^{-5}$ inhabitants (inh.). `r round(100 * sum(Dfr$deaths) / sum(country_data$pop), 1)` deaths $10^{-5}$ inhabitants (inh.).
......
...@@ -278,7 +278,7 @@ if ( .Platform$OS.type == "unix") { ...@@ -278,7 +278,7 @@ if ( .Platform$OS.type == "unix") {
## utility for text output : takes a vector of names (argument nam) ## utility for text output : takes a vector of names (argument nam)
## and a vector of counts (cnt), and returns a string with the names ## and a vector of counts (cnt), and returns a string with the names
## and counts within brackets, separated with commas, wwith "and" for ## and counts within brackets, separated with commas, with "and" for
## the last one ## the last one
collapse <- function(nam = onam, cnt = nd){ collapse <- function(nam = onam, cnt = nd){
......
...@@ -39,7 +39,19 @@ plan <- drake_plan(## raw_data = read_excel( ...@@ -39,7 +39,19 @@ plan <- drake_plan(## raw_data = read_excel(
"Georgia", "Israel", "Jordan", "Lebanon", "Libya", "Georgia", "Israel", "Jordan", "Lebanon", "Libya",
"Moldova", "Morocco", "Syria", "Tunisia", "Ukraine"), "Moldova", "Morocco", "Syria", "Tunisia", "Ukraine"),
europe = standardise_country_names(sort(c(eu28, efta, candi, noneu))), xeurope_countries =
enframe(
list(EU28 = eu28, EFTA = efta, Candidates = candi, Non_EU = noneu),
name = "group",
value = "name"
) %>%
unnest(cols = name) %>%
mutate(
name = standardise_country_names(name),
group = fct_inorder(group)
) %>%
select(name, group) %>%
arrange(name),
wca = c("Cameroon", "Central African Republic", "Chad", wca = c("Cameroon", "Central African Republic", "Chad",
"Congo DR", "Congo", "Equatorial Guinea", "Gabon", "Congo DR", "Congo", "Equatorial Guinea", "Gabon",
...@@ -87,6 +99,7 @@ plan <- drake_plan(## raw_data = read_excel( ...@@ -87,6 +99,7 @@ plan <- drake_plan(## raw_data = read_excel(
## policy responses around the world, rigorously and consistently. ## policy responses around the world, rigorously and consistently.
lock = stringency(), lock = stringency(),
## CARTOGRAPHY --------------------------------------------------- ## CARTOGRAPHY ---------------------------------------------------
world_map = get_world_map(), world_map = get_world_map(),
...@@ -95,8 +108,8 @@ plan <- drake_plan(## raw_data = read_excel( ...@@ -95,8 +108,8 @@ plan <- drake_plan(## raw_data = read_excel(
## candidate countries + non-EU countries). Source GADM.org ## candidate countries + non-EU countries). Source GADM.org
## version 3.6 ## version 3.6
geo_europe_light = geosimplify( geo_europe_light = geosimplify(
world_map[world_map$name %in% world_map[world_map$name %in% xeurope_countries$name, ]
standardise_country_names(europe), ]), ),
roi_europe_light = region_of_interest( roi_europe_light = region_of_interest(
geo_europe_light, world_map), geo_europe_light, world_map),
...@@ -119,7 +132,7 @@ plan <- drake_plan(## raw_data = read_excel( ...@@ -119,7 +132,7 @@ plan <- drake_plan(## raw_data = read_excel(
## Population counts in thousands of people ## Population counts in thousands of people
pop_countries_2020 = subset(world_population, pop_countries_2020 = subset(world_population,
subset = name %in% europe), subset = name %in% xeurope_countries$name),
## ## today (ANSI) ## ## today (ANSI)
## tod = format(Sys.Date(), "%Y%m%d"), ## tod = format(Sys.Date(), "%Y%m%d"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment