ann_tab_long: Create long annual tables from line listing data

View source: R/ann_tab_long.R

ann_tab_longR Documentation

Create long annual tables from line listing data

Description

From FY 2018/19, annual tables will be moving to a long format rather than a wide format. This function takes line-listing data and aggregates by organisation and time period, producing counts of cases by a given metric (apportioning or prior healthcare exposure).

Usage

ann_tab_long(dat, collection_var, org_var, metric_var, period_var)

Arguments

dat

A dataframe containing line-listing data

collection_var

A string giving the data collection

org_var

The variable giving the organisation code

metric_var

Column in dat giving column for the metric

period_var

Column giving the period by which counts should be aggregated

Details

The data are expanded to cover time periods in the data, but there may well be organisations that are not in the line-listing data that will be merged in later to make a complete table.

In addition, PHEC and organisation names will need to be merged in, as will denominator data, and rates will need to be calculated.

Value

A dataframe with counts of cases in long format, by organisation and time period

Examples

library(dplyr)
data(line_listing)
line_listing$fy_long <- fy_long(line_listing$specimen_date)

line_listing %>%
  filter(collection == "C. difficile") %>%
  ann_tab_long(dat = ., collection_var = collection,
    org_var = reporting_organisation_code,
    metric_var = prior_hc, period_var = fy_long)

PublicHealthEngland/hcaidcs documentation built on Jan. 19, 2024, 8:38 a.m.