| ann_tab_long | R Documentation | 
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).
ann_tab_long(dat, collection_var, org_var, metric_var, period_var)
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  | 
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.
A dataframe with counts of cases in long format, by organisation and time period
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.