Skip to content

Commit

Permalink
release candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Jul 1, 2021
1 parent 1e095cb commit 4e1b981
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Expand Up @@ -27,4 +27,4 @@ SMG.md
^.*.pdf$
^inst/paper$
^inst/examples$
^\.devcontainer$
^\.devcontainer$
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Expand Up @@ -36,6 +36,7 @@ repos:
.*\.RData|
.*\.png|
.*\.bib|
.*\.csv|
cran-comments\.md
)$
- id: lintr
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Expand Up @@ -19,7 +19,7 @@ Thanks to @joseph-palmer, @RichardMN, and @kathsherratt for contributions toward
## Other changes

* Testing of classes updated to allow for at least one of `common_data_urls` or `level_data_urls` to be present. The previous default which forced the presence of `common_data_urls` meant that several classes had to define an empty field (by @joseph-palmer).
* Tests on data sets are now included as a method in `DataClass`. `test_regional-datasets` now calls the test function for all classes at each level. Data set specific tests (such as for NHS regions in the UK) are included as a `specific_tests` function within the country class, which is called by the parent (DataClass) `test` after performing standard checks. This allows all the code about a country to be defined in its own class. In addition, users can run tests interactively by calling the test method (e.g. `$test()`;) (by @joseph-palmer)
* Tests on data sets are now included as a method in `DataClass`. `test_regional-datasets` now calls the test function for all classes at each level. Data set specific tests (such as for NHS regions in the UK) are included as a `specific_tests` function within the country class, which is called by the parent (DataClass) `test` after performing standard checks. This allows all the code about a country to be defined in its own class. In addition, users can run tests interactively by calling the test method (e.g. `$test()`) (by @joseph-palmer)
* A function to create a template class and automatically add a github workflow file has been added. This makes adding a new data source for a country even easier as now you can call the function `make_new_data_source()` with the country / source name to add and it will set up the basic structure for you. There is also now a github check to make sure all new sources have a workflow set up (by @joseph-palmer).
* Adds `source_` fields to all data sets to help users properly attribute their data sources (by @RichardMN).

Expand Down
2 changes: 1 addition & 1 deletion R/Canada.R
Expand Up @@ -42,7 +42,7 @@ Canada <- R6::R6Class("Canada",
#' @field source_url Website address for explanation/introduction of the
#' data
source_url = "https://open.canada.ca/data/en/dataset/261c32ab-4cfd-4f81-9dea-7b64065690dc", # nolint

#' @description Set up a table of region codes for clean data
#' @importFrom tibble tibble
set_region_codes = function() {
Expand Down
3 changes: 2 additions & 1 deletion R/Switzerland.R
Expand Up @@ -106,7 +106,8 @@ Switzerland <- R6::R6Class("Switzerland",
level_1_region_code = if_else(
.data$abbreviation_canton_and_fl == "FL",
"FL-FL",
paste0("CH-", .data$abbreviation_canton_and_fl)),
paste0("CH-", .data$abbreviation_canton_and_fl)
),
date = as_date(ymd(.data$date))
) %>%
left_join(
Expand Down
51 changes: 28 additions & 23 deletions R/UK.R
Expand Up @@ -385,38 +385,43 @@ UK <- R6::R6Class("UK",
# 1. Data from 7 April 2021 to now:
# Data not always daily; set up to try urls for last 7 days
try_date_seq <- seq.Date(self$release_date,
by = -1, length.out = 7)
try_urls <- map_chr(try_date_seq,
~ paste0(
self$data_urls[["nhs_recent_url"]],
"/wp-content/uploads/sites/2/",
year(.x), "/",
ifelse(month(.x) < 10,
paste0(0, month(.x)),
month(.x)
),
"/COVID-19-daily-admissions-and-beds-",
gsub("-", "", as.character(.x)),
".xlsx")
)
by = -1, length.out = 7
)
try_urls <- map_chr(
try_date_seq,
~ paste0(
self$data_urls[["nhs_recent_url"]],
"/wp-content/uploads/sites/2/",
year(.x), "/",
ifelse(month(.x) < 10,
paste0(0, month(.x)),
month(.x)
),
"/COVID-19-daily-admissions-and-beds-",
gsub("-", "", as.character(.x)),
".xlsx"
)
)

names(try_urls) <- try_date_seq
# Check for working urls
url_status <- map_chr(try_urls,
~ GET(.x) %>%
status_code())
url_status <- map_chr(
try_urls,
~ GET(.x) %>%
status_code()
)
# Keep latest working url
url_status <- url_status[(url_status == 200)]
names(url_status) <- as.Date(names(url_status))
nhs_recent_url <- try_urls[as.character(max(names(url_status)))]
# Get latest url download
recent <- download_excel(nhs_recent_url,
"nhs_recent.xlsx",
verbose = self$verbose,
transpose = TRUE,
sheet = 1,
range = cell_limits(c(28, 2), c(36, NA))
)
"nhs_recent.xlsx",
verbose = self$verbose,
transpose = TRUE,
sheet = 1,
range = cell_limits(c(28, 2), c(36, NA))
)

# 2. Data for August 2020 to 7 April 2021
archive <- download_excel(
Expand Down
4 changes: 3 additions & 1 deletion R/shared-methods.R
Expand Up @@ -510,7 +510,9 @@ DataClass <- R6::R6Class(
"national", "regional"
),
data_urls = paste(unlist(self$data_urls), collapse = ", "),
source_data_cols = paste(unlist(self$source_data_cols), collapse = ", "),
source_data_cols = paste(unlist(self$source_data_cols),
collapse = ", "
),
source_text = ifelse(is.null(self$source_text), NA, self$source_text),
source_url = ifelse(is.null(self$source_url), NA, self$source_url)
)
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Expand Up @@ -15,7 +15,7 @@ knitr::opts_chunk$set(

[![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)

[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/epiforecasts/covidregionaldata/blob/master/LICENSE.md/) [![GitHub contributors](https://img.shields.io/github/contributors/epiforecasts/covidregionaldata)](https://github.com/epiforecasts/covidregionaldata/graphs/contributors) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://makeapullrequest.com/) [![GitHub commits](https://img.shields.io/github/commits-since/epiforecasts/covidregionaldata/v0.9.2.svg?color=orange)](https://GitHub.com/epiforecasts/covidregionaldata/commit/master/) [![DOI](https://zenodo.org/badge/271601189.svg)](https://zenodo.org/badge/latestdoi/271601189)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/epiforecasts/covidregionaldata/blob/master/LICENSE.md/) [![GitHub contributors](https://img.shields.io/github/contributors/epiforecasts/covidregionaldata)](https://github.com/epiforecasts/covidregionaldata/graphs/contributors) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://makeapullrequest.com/) [![GitHub commits](https://img.shields.io/github/commits-since/epiforecasts/covidregionaldata/0.9.2.svg?color=orange)](https://GitHub.com/epiforecasts/covidregionaldata/commit/master/) [![DOI](https://zenodo.org/badge/271601189.svg)](https://zenodo.org/badge/latestdoi/271601189)

[![status](https://joss.theoj.org/papers/dd6f7acdae3b7136a3ac373ce9a0655c/status.svg)](https://joss.theoj.org/papers/dd6f7acdae3b7136a3ac373ce9a0655c)

Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -16,7 +16,7 @@ contributors](https://img.shields.io/github/contributors/epiforecasts/covidregio
[![PRs
Welcome](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://makeapullrequest.com/)
[![GitHub
commits](https://img.shields.io/github/commits-since/epiforecasts/covidregionaldata/v0.9.2.svg?color=orange)](https://GitHub.com/epiforecasts/covidregionaldata/commit/master/)
commits](https://img.shields.io/github/commits-since/epiforecasts/covidregionaldata/0.9.2.svg?color=orange)](https://GitHub.com/epiforecasts/covidregionaldata/commit/master/)
[![DOI](https://zenodo.org/badge/271601189.svg)](https://zenodo.org/badge/latestdoi/271601189)

[![status](https://joss.theoj.org/papers/dd6f7acdae3b7136a3ac373ce9a0655c/status.svg)](https://joss.theoj.org/papers/dd6f7acdae3b7136a3ac373ce9a0655c)
Expand Down Expand Up @@ -79,7 +79,7 @@ the temporary directory by default),

``` r
start_using_memoise()
#> Using a cache at: /tmp/RtmpB2UKDX
#> Using a cache at: /tmp/RtmpMMiVQw
```

To stop using `memoise` use,
Expand All @@ -104,7 +104,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: 129165 Columns: 8
#> Rows: 129279 Columns: 8
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (3): Country_code, Country, WHO_region
Expand All @@ -116,7 +116,7 @@ nots <- get_national_data()
#> Cleaning data
#> Processing data
nots
#> # A tibble: 129,165 x 15
#> # A tibble: 129,401 x 15
#> date un_region who_region country iso_code cases_new cases_total
#> <date> <chr> <chr> <chr> <chr> <dbl> <dbl>
#> 1 2020-01-03 Asia EMRO Afghanistan AF 0 0
Expand All @@ -129,7 +129,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 129,155 more rows, and 8 more variables: deaths_new <dbl>,
#> # … with 129,391 more rows, and 8 more variables: deaths_new <dbl>,
#> # deaths_total <dbl>, recovered_new <dbl>, recovered_total <dbl>,
#> # hosp_new <dbl>, hosp_total <dbl>, tested_new <dbl>, tested_total <dbl>
```
Expand Down
79 changes: 40 additions & 39 deletions inst/WORDLIST
@@ -1,100 +1,101 @@
ac
ACAPS
afghanistan
api
APL
apskritis
Bundesland
cloneable
CMD
CMMID
COVID
CSSE
CoV
Codecov
Cota
Covid
DD
DataClass
ECDC
Estados
Github
GoogleData
Guidotti
ICD
INEGI
IPC
Inf
Initalize
JHU
JRC
Kreise
Landkreis
Linelist
MX
Meixco
OSP
OpenDataZH
PHE
PRs
RVIM
SARS
SciELOPreprints
SouthAfrica
UCPM
YYYY
ac
afghanistan
api
apskritis
cloneable
com
conuntry
Cota
CoV
covid
Covid
COVID
covidregionaldata
CSSE
DataClass
datahub
dd
DD
documentaion
doi
ec
ECDC
Estados
etc
filepath
fns
geocode
geocoding
github
Github
GoogleData
Guidotti
hexsticker
ICD
inciteful
inegi
INEGI
Inf
initalize
Initalize
IPC
iso
JHU
jrc
JRC
jure
Kreise
Landkreis
linelist
Linelist
linelists
ltla
magrittr
md
Meixco
memoise
metacran
MX
nhs
nhsregions
OpenDataZH
org
OSP
params
paulcampbell
PHE
PRs
quickstart
rds
recomended
regioni
reparameterise
RVIM
SARS
savivaldybe
SciELOPreprints
seperate
shapefiles
SouthAfrica
spi
st
subnationaldata
supertracker
testthat
tibble
tibbles
UCPM
uk
urls
useMemoise
utla
wikipedia
yaml
yyyy
YYYY
Binary file modified man/figures/README-g7_plot-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions tests/testthat/test-get_available_datasets.R
Expand Up @@ -42,11 +42,13 @@ test_that(

# test each column for na values
for (name in colnames(data)) {
if (name %in% c("level_1_region",
"level_2_region",
"level_3_region",
"source_text",
"source_url")) {
if (name %in% c(
"level_1_region",
"level_2_region",
"level_3_region",
"source_text",
"source_url"
)) {
next
}
test_that(
Expand Down

0 comments on commit 4e1b981

Please sign in to comment.