Package 'covid19.nhs.data'

Title: NHS Trust Level COVID-19 Data Aggregated to a Range of Spatial Scales
Description: Facilitates access to data on NHS trust level COVID-19 data aggregated to a range of spatial scales.
Authors: Sophie Meakin [aut, cre] , Sam Abbott [aut] , Hannah Choi [aut], Sebastian Funk [aut], Hugo Gruson [ctb]
Maintainer: Sophie Meakin <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-08-18 04:33:44 UTC
Source: https://github.com/epiforecasts/covid19.nhs.data

Help Index


Download English Hospital Trust Admissions Data

Description

Downloads English hospital admissions data by Trust. Data is released each Thursday. See here for details: https://www.england.nhs.uk/statistics/statistical-work-areas/covid-19-hospital-activity/

Usage

download_trust_data(release_date = Sys.Date())

Arguments

release_date

Date, release date of data to download. Will automatically find the Thursday prior to the date specified.

Value

A data.frame of hospital admissions by trust.


LTLA Shapefile for England

Description

LTLA Shapefile for England

Usage

england_ltla_shape

Format

An object of class sf (inherits from tbl_df, tbl, data.frame) with 314 rows and 11 columns.


UTLA Shapefile for England

Description

UTLA Shapefile for England

Usage

england_utla_shape

Format

An object of class sf (inherits from tbl_df, tbl, data.frame) with 151 rows and 11 columns.


Get Hospital Admissions

Description

Downloads hospital admissions by Hospital trust using download_trust_data and then optionally aggregates to either LTLA or UTLA level. This can be done either with the built in mapping or a user supplied mapping.

Usage

get_admissions(
  keep_vars = "new_adm",
  level = "trust",
  release_date = Sys.Date(),
  mapping,
  geo_names
)

Arguments

keep_vars

Character string, defaulting to "new_adm" (first-time COVID-19 hospital admissions). Defines which variables to keep from the raw data. Other supported options are: "all_adm" (for all COVID-19 hospital admissions), and "all_bed" (for all COVID-19 beds occupied). Multiple values allowed.

level

Character string, defaulting to "trust". Defines the level of aggregation at which to return the data. Other supported options are "utla" for UTLA level admissions or "ltla" for LTLA level admissions.

release_date

Date, release date of data to download. Will automatically find the Thursday prior to the date specified.

mapping

A data.frame containing geo_code, trust_code, p_geo and p_trust.

geo_names

A data.frame containing geo_code and geo_name. Used to assign meaningful to geographies.

Value

A data.frame of daily admissions and/or bed occupancy data, reported at the Trust, LTLA or UTLA level. Note that new admissions ("new_adm") are called "admissions" in the data.frame to be consistent with a previous version of this function.


Link Mapping to Trust and Geography Names

Description

Link Mapping to Trust and Geography Names

Usage

get_names(mapping, geo_names)

Arguments

mapping

A data.frame containing geo_code, trust_code, p_geo and p_trust.

geo_names

A data.frame containing geo_code and geo_name. Used to assign meaningful to geographies.

Value

A data.frame containing a UTLA to trust level admissions map combined meaningful names.


Load local authority to Trust mappings

Description

Load LTLA- or UTLA-Trust mappings from two data sources: HES (Hospital Episodes Statistics) until September 2020, and linked COVID-19 cases and admissions June 2020 - May 2021. Replaces previous datasets trust_ltla_mapping and trust_utla_mapping (the HES mappings).

Usage

load_mapping(scale, source)

Arguments

scale

Character string defining the geographical scale. Supported options are "ltla" (lower-tier local authority) and "utla" (upper-tier local authority).

source

Character string defining the souce of the mapping. supported options are "link" (linked COVID-19 cases and admissions) and "sus" (Secondary Uses Service, originally the only mapping available).

Value

A data.frame with the following columns: geo_code (9-digit LTLA or UTLA ID); trust_code; n (the number of reported admissions); p_geo (the proportion of all admissions from a LTLA/UTLA that go to a given Trust); p_trust (the proportion of all admissions to a Trust that come from a given LTLA/UTLA); source ("SUS" or "Link"); and level ("ltla" or "utla").


Linking File Between LTLA Codes and Names

Description

Linking File Between LTLA Codes and Names

Usage

ltla_names

Format

An object of class tbl_df (inherits from tbl, data.frame) with 340 rows and 2 columns.


Map Admissions

Description

Map NHS Hospital aggregated admissions. By default this maps the latest data provided.

Usage

map_admissions(admissions, shapefile, date, scale_fill)

Arguments

admissions

A data.frame of admissions data as produced by get_dadmissions. Must contain the following variables: geo_code, date, and admissions

shapefile

A shapefile defaults to england_utla_shape if not supplied.

date

A date variable (or vector) indicating when to plot data for. If set to NULL then no date filter is applied

scale_fill

A ggplot2 scale_fill used to define the fill colours used in the map. The default is: scale_fill_viridis_c(option = "viridis", direction = -1, na.value = "grey80").

Value

A map of Covid-19 admissions in England


Summarise Trust Mapping

Description

Summarise the Trust mapping (currently only supports the UTLA mapping) both graphically and in a table.

Usage

summarise_mapping(
  trust = NULL,
  geography = NULL,
  mapping,
  shapefile,
  geo_names
)

Arguments

trust

A character string indicating a trust of interest.

geography

A character string indicating the geography of interest. Only used if trust is not specified. Related to the mapping used so for trust_utla_mapping refers to a UTLA.

mapping

A data.frame containing geo_code, trust_code, p_geo and p_trust.

shapefile

A shapefile defaults to england_utla_shape if not supplied.

geo_names

A data.frame containing geo_code and geo_name. Used to assign meaningful to geographies.

Value

A table and optional map summarising the admissions mapping.


List of Trust Mergers

Description

List of Trust Mergers

Usage

trust_mergers

Format

An object of class spec_tbl_df (inherits from tbl_df, tbl, data.frame) with 11 rows and 3 columns.


Linking File Between NHS Trust Codes and Names

Description

Linking File Between NHS Trust Codes and Names

Usage

trust_names

Format

An object of class tbl_df (inherits from tbl, data.frame) with 228 rows and 2 columns.


Linking File Between UTLA Codes and Names

Description

Linking File Between UTLA Codes and Names

Usage

utla_names

Format

An object of class tbl_df (inherits from tbl, data.frame) with 174 rows and 2 columns.