diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f84236d..4cf6f352 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: rev: v3.4.0 hooks: - id: check-added-large-files - args: ['--maxkb=200'] + args: ['--maxkb=800'] - id: end-of-file-fixer exclude: '\.Rd' - repo: local diff --git a/DESCRIPTION b/DESCRIPTION index 2e9908f2..a3590fd0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -68,8 +68,8 @@ Description: An interface to subnational and national level COVID-19 data the UK, and from other Covid-19 data collections, including the World Health Organisation (WHO), European Centre for Disease Prevention and Control (ECDC), John Hopkins University (JHU), Google Open Data and - others. Designed to streamline Covid-19 data extraction, cleaning, - and processing from a range of data sources in an open and transparent + others. Designed to streamline Covid-19 data extraction, cleaning, and + processing from a range of data sources in an open and transparent way. This allows users to inspect and scrutinise the data, and tools used to process it, at every step. For all countries supported, data includes a daily time-series of cases. Wherever available data is also @@ -103,6 +103,7 @@ Imports: xml2 Suggests: ggplot2, + ggspatial, knitr, mockery, pkgdown, diff --git a/README.Rmd b/README.Rmd index 348726d5..bf2d3ccf 100644 --- a/README.Rmd +++ b/README.Rmd @@ -11,7 +11,7 @@ knitr::opts_chunk$set( ) ``` -# Subnational data for the COVID-19 outbreak +# Subnational data for the COVID-19 outbreak [![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![R-CMD-check](https://github.com/epiforecasts/covidregionaldata/workflows/R-CMD-check/badge.svg)](https://github.com/epiforecasts/covidregionaldata/actions) [![Codecov test coverage](https://codecov.io/gh/epiforecasts/covidregionaldata/branch/master/graph/badge.svg)](https://codecov.io/gh/epiforecasts/covidregionaldata?branch=master) [![Data status](https://img.shields.io/badge/Data-status-lightblue.svg?style=flat)](https://epiforecasts.io/covidregionaldata/articles/supported-countries.html) [![metacran downloads](http://cranlogs.r-pkg.org/badges/grand-total/covidregionaldata?color=ff69b4)](https://cran.r-project.org/package=covidregionaldata) diff --git a/README.md b/README.md index b856afa3..dd1c31f1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Subnational data for the COVID-19 outbreak +# Subnational data for the COVID-19 outbreak [![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) @@ -27,11 +27,11 @@ both official sources, such as Public Health England in the UK, and from other Covid-19 data collections, including the World Health Organisation (WHO), European Centre for Disease Prevention and Control (ECDC), John Hopkins University (JHU), Google Open Data and others. This package is -designed to streamline Covid-19 data extraction, cleaning, and processing -from a range of data sources in an open and transparent way. This allows -users to inspect and scrutinise the data, and tools used to process it, -at every step. For all countries supported, data includes a daily -time-series of cases and, wherever available, data on deaths, +designed to streamline Covid-19 data extraction, cleaning, and +processing from a range of data sources in an open and transparent way. +This allows users to inspect and scrutinise the data, and tools used to +process it, at every step. For all countries supported, data includes a +daily time-series of cases and, wherever available, 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. @@ -78,7 +78,7 @@ the temporary directory by default), ``` r start_using_memoise() -#> Using a cache at: /tmp/RtmpJAeC7J +#> Using a cache at: /tmp/RtmpXdh1Cd ``` To stop using `memoise` use, @@ -103,7 +103,7 @@ the Google COVID-19 open data project), use: ``` r nots <- get_national_data() #> Downloading data from https://covid19.who.int/WHO-COVID-19-global-data.csv -#> Rows: 124,425 +#> Rows: 128,546 #> Columns: 8 #> Delimiter: "," #> chr [3]: Country_code, Country, WHO_region @@ -115,7 +115,7 @@ nots <- get_national_data() #> Cleaning data #> Processing data nots -#> # A tibble: 124,425 x 15 +#> # A tibble: 128,690 x 15 #> date un_region who_region country iso_code cases_new cases_total #> #> 1 2020-01-03 Asia EMRO Afghanistan AF 0 0 @@ -128,7 +128,7 @@ nots #> 8 2020-01-03 Americas AMRO Antigua & Bar… AG 0 0 #> 9 2020-01-03 Americas AMRO Argentina AR 0 0 #> 10 2020-01-03 Asia EURO Armenia AM 0 0 -#> # … with 124,415 more rows, and 8 more variables: deaths_new , +#> # … with 128,680 more rows, and 8 more variables: deaths_new , #> # deaths_total , recovered_new , recovered_total , #> # hosp_new , hosp_total , tested_new , tested_total ``` @@ -169,7 +169,7 @@ for example by level 1 region in the UK, use: ``` r uk_nots <- get_regional_data(country = "UK", verbose = FALSE) uk_nots -#> # A tibble: 6,474 x 26 +#> # A tibble: 6,695 x 26 #> date region region_code cases_new cases_total deaths_new deaths_total #> #> 1 2020-01-30 East Mi… E12000004 NA NA NA NA @@ -182,7 +182,7 @@ uk_nots #> 8 2020-01-30 Scotland S92000003 NA NA NA NA #> 9 2020-01-30 South E… E12000008 NA NA NA NA #> 10 2020-01-30 South W… E12000009 NA NA NA NA -#> # … with 6,464 more rows, and 19 more variables: recovered_new , +#> # … with 6,685 more rows, and 19 more variables: recovered_new , #> # recovered_total , hosp_new , hosp_total , tested_new , #> # tested_total , areaType , cumCasesByPublishDate , #> # cumCasesBySpecimenDate , newCasesByPublishDate , @@ -256,10 +256,10 @@ using the following, [![Development](https://img.shields.io/badge/Wiki-lightblue.svg?style=flat)](https://github.com/epiforecasts/covidregionaldata/wiki/) -This package is the result of work from a number of contributors -(see contributors list in the -[here](https://epiforecasts.io/covidregionaldata/authors.html)). -We would like to thank the [CMMID COVID-19 working +This package is the result of work from a number of contributors (see +contributors list +[here](https://epiforecasts.io/covidregionaldata/authors.html)). We +would like to thank the [CMMID COVID-19 working group](https://cmmid.github.io/groups/ncov-group.html) for inciteful comments and feedback. diff --git a/inst/WORDLIST b/inst/WORDLIST index e016cd85..fe06356c 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -166,6 +166,7 @@ geocoding getRversion GFM ggplot +ggspatial Gimma github Github @@ -190,6 +191,7 @@ HDTRA Healy hellewell Hellewell +Hexsticker Hiroaki hl Hongru diff --git a/inst/make_hexsticker.R b/inst/make_hexsticker.R new file mode 100644 index 00000000..432af96b --- /dev/null +++ b/inst/make_hexsticker.R @@ -0,0 +1,102 @@ +library(covidregionaldata) +library(hexSticker) +library(showtext) +library(ggplot2) +library(dplyr) +library(maps) +library(countrycode) +library(sf) +library(rnaturalearth) +library(rmapshaper) + +# font setup +font_add_google("Zilla Slab Highlight", "useme") + +# get countries we have data for +regional_countries <- get_available_datasets() %>% + filter(.data$type == "regional") + +regional_countries_l2 <- regional_countries %>% + filter(!(is.na(.data$level_2_region))) + +regional_countries_l1 <- regional_countries %>% + filter(is.na(.data$level_2_region)) + +# Approach using Natural Earth data + +world_without_regions <- ne_countries(returnclass = "sf") %>% + filter(sovereignt != "Antarctica") + +# numberOfLevels should be less than half the number of colours in the +# divergent palette used (usually 7) +numberOfLevels <- 3 + +regional_maps_l1 <- ms_simplify( + ne_states(gsub(" \\(.*\\)", "", + regional_countries_l1$origin, + perl = TRUE + ), returnclass = "sf") %>% + mutate(region_code = woe_id %% numberOfLevels), + keep = 0.04 +) + +regional_maps_l2 <- ms_simplify( + ne_states(gsub(" \\(.*\\)", "", + regional_countries_l2$origin, + perl = TRUE + ), returnclass = "sf") %>% + mutate(region_code = woe_id %% numberOfLevels + numberOfLevels + 1), + keep = 0.04 +) + +regional_maps <- bind_rows(regional_maps_l1, regional_maps_l2) + +# We keep 50% of the points of the country outlines because it's a +# finer scale map +# We add the US and the UK to the list because otherwise we don't +# successfully include them. +regional_outlines <- ms_lines( + ms_simplify( + ne_countries( + country = c( + gsub(" \\(.*\\)", "", regional_countries$origin, perl = TRUE), + "United States", "United Kingdom" + ), + returnclass = "sf" + ), + keep = 0.1, + scale = 50 + ) +) + +covid_map <- ggplot() + + ggspatial::layer_spatial(data = world_without_regions, size = 0.01) + + ggspatial::layer_spatial( + data = regional_maps, + aes(fill = region_code), size = 0.02 + ) + + ggspatial::layer_spatial( + data = regional_outlines, + aes(colour = factor(RANK)), size = 0.1 + ) + + coord_sf(crs = "ESRI:54016") + + scale_fill_fermenter(palette = "RdBu") + + theme_void() + + scale_colour_manual(name = "", values = c("black", "black", "black")) + + theme(legend.position = "none", axis.text.x = element_blank()) + +print(covid_map) + +logo <- sticker( + covid_map, + package = "covidregionaldata", + p_size = 48, s_x = 1, s_y = 0.8, s_width = 1.7, s_height = 1.7, + p_y = 1.45, + p_color = "white", + p_family = "useme", + h_color = "#646770", + h_fill = "#24A7DF", + filename = "man/figures/logo.png", + u_size = 3.5, + dpi = 1000 +) diff --git a/man/figures/README-g7_plot-1.png b/man/figures/README-g7_plot-1.png index f1a8b934..027f358d 100644 Binary files a/man/figures/README-g7_plot-1.png and b/man/figures/README-g7_plot-1.png differ diff --git a/man/figures/README-uk_plot-1.png b/man/figures/README-uk_plot-1.png index 0d57407d..d7c4fd40 100644 Binary files a/man/figures/README-uk_plot-1.png and b/man/figures/README-uk_plot-1.png differ diff --git a/man/figures/logo.png b/man/figures/logo.png new file mode 100644 index 00000000..ecbb5d58 Binary files /dev/null and b/man/figures/logo.png differ