Description Super class Public fields Methods Source See Also Examples
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).
covidregionaldata::DataClass
-> UK
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
set_region_codes()
Specific function for getting region codes for UK .
UK$set_region_codes()
download()
UK specific download()
function.
UK$download()
clean_level_1()
Region Level Data Cleaning
UK$clean_level_1()
clean_level_2()
Level 2 Data Cleaning
UK$clean_level_2()
new()
Initalize the UK Class
UK$new(nhsregions = FALSE, release_date = NULL, resolution = "utla", ...)
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.
\dontrun{ UK$new( level = 1, localise = TRUE, verbose = True, steps = FALSE, nhsregions = FALSE, release_date = NULL, resolution = "utla" ) }
download_filter()
Helper function for downloading data API
UK$download_filter(filter)
filter
region filters
set_filters()
Set filters for UK data api query.
UK$set_filters()
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"
UK$download_nhs_regions()
nhs data.frame of nhs regions
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"
UK$add_nhs_regions(clean_data, nhs_data)
clean_data
Cleaned UK covid-19 data
nhs_data
NHS region data
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.
UK$specific_tests( self_copy, download = FALSE, all = FALSE, snapshot_path = "", ... )
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
clone()
The objects of this class are cloneable with this method.
UK$clone(deep = FALSE)
deep
Whether to make a deep clone.
https://coronavirus.data.gov.uk/details/download
https://coronavirus.data.gov.uk/details/download
Subnational data sources
Belgium
,
Brazil
,
Canada
,
Colombia
,
Covid19DataHub
,
Cuba
,
Estonia
,
France
,
Germany
,
Google
,
India
,
Italy
,
JHU
,
Lithuania
,
Mexico
,
Netherlands
,
SouthAfrica
,
Switzerland
,
USA
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 | ## Not run:
# 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
## End(Not run)
## ------------------------------------------------
## Method `UK$new`
## ------------------------------------------------
## Not run:
UK$new(
level = 1, localise = TRUE,
verbose = True, steps = FALSE,
nhsregions = FALSE, release_date = NULL,
resolution = "utla"
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.