United Kingdom Class for downloading, cleaning and processing notification data.
Source:R/UK.R
UK.Rd
Extracts daily COVID-19 data for the UK, stratified by region and nation. Additional options for this class are: to return subnational English regions using NHS region boundaries instead of PHE boundaries (nhsregions = TRUE), a release date to download from (release_date) and a geographical resolution (resolution).
See also
Subnational data sources
Belgium
,
Brazil
,
Canada
,
Colombia
,
Covid19DataHub
,
Cuba
,
Estonia
,
France
,
Germany
,
Google
,
India
,
Italy
,
JHU
,
Lithuania
,
Mexico
,
Netherlands
,
SouthAfrica
,
Switzerland
,
USA
Public fields
origin
name of origin to fetch data for
supported_levels
A list of supported levels.
supported_region_names
A list of region names in order of level.
supported_region_codes
A list of region codes in order of level.
common_data_urls
List of named links to raw data. The first, and only entry, is be named main.
level_data_urls
List of named links to raw data that are level specific.
source_data_cols
existing columns within the raw data
source_text
Plain text description of the source of the data
source_url
Website address for explanation/introduction of the data
query_filters
Set what filters to use to query the data
nhsregions
Whether to include NHS regions in the data
release_date
The release date for the data
resolution
The resolution of the data to return
authority_data
The raw data for creating authority lookup tables
Methods
Inherited methods
Method new()
Initalize the UK Class
Usage
UK$new(nhsregions = FALSE, release_date = NULL, resolution = "utla", ...)
Arguments
nhsregions
Return subnational English regions using NHS region boundaries instead of PHE boundaries.
release_date
Date data was released. Default is to extract latest release. Dates should be in the format "yyyy-mm-dd".
resolution
"utla" (default) or "ltla", depending on which geographical resolution is preferred
...
Optional arguments passed to
DataClass()
initalize.
Method download_nhs_regions()
Download NHS data for level 1 regions Separate NHS data is available for "first" admissions, excluding readmissions. This is available for England + English regions only. Data are available separately for the periods 2020-08-01 to 2021-04-06, and 2021-04-07 - present. See: https://www.england.nhs.uk/statistics/statistical-work-areas/covid-19-hospital-activity/ Section 2, "2. Estimated new hospital cases"
Method add_nhs_regions()
Add NHS data for level 1 regions Separate NHS data is available for "first" admissions, excluding readmissions. This is available for England + English regions only. See: https://www.england.nhs.uk/statistics/statistical-work-areas/covid-19-hospital-activity/ Section 2, "2. Estimated new hospital cases"
Method specific_tests()
Specific tests for UK data. In addition to generic tests ran
by DataClass$test()
data for NHS regions are downloaded and ran through
the same generic checks (test_cleaning, test_processing, test_return). If
download = TRUE or a snapshot file is not found, the nhs data is
downloaded and saved to the snapshot location provided. If an existing
snapshot file is found then this data is used in the next tests.
Tests data can be downloaded, cleaned, processed and returned. Designed
to be ran from test
and not ran directly.
Arguments
self_copy
R6class the object to test.
download
logical. To download the data (TRUE) or use a snapshot (FALSE). Defaults to FALSE.
all
logical. Run tests with all settings (TRUE) or with those defined in the current class instance (FALSE). Defaults to FALSE.
snapshot_path
character_array the path to save the downloaded snapshot to. Works on the snapshot path constructed by
test
but adds...
Additional parameters to pass to
specific_tests
Examples
if (FALSE) {
# setup a data cache
start_using_memoise()
# download, clean and process level 1 UK data with hospital admissions
region <- UK$new(level = "1", nhsregions = TRUE)
region$return()
# initialise level 2 data
utla <- UK$new(level = "2")
# download UTLA data
utla$download()
# clean UTLA data
utla$clean()
# inspect available level 1 regions
utla$available_regions(level = "1")
# filter data to the East of England
utla$filter("East of England")
# process UTLA data
utla$process()
# return processed and filtered data
utla$return()
# inspect all data steps
utla$data
}
## ------------------------------------------------
## Method `UK$new`
## ------------------------------------------------
if (FALSE) {
UK$new(
level = 1, localise = TRUE,
verbose = True, steps = FALSE,
nhsregions = FALSE, release_date = NULL,
resolution = "utla"
)
}