mo_tab_long: mo_tab_long

View source: R/mo_tab_long.R

mo_tab_longR Documentation

mo_tab_long

Description

Takes line list data and aggregates to long data for saving as long-format monthly tables. Outputs are also sorted by organisation, time and metric.

Usage

mo_tab_long(dat, collection_var, metric_var, org_var, year_var, month_var)

Arguments

dat

A dataframe containing line-listing data

collection_var

A string giving the data collection

metric_var

Column in dat giving column for the metric

org_var

The variable giving the organisation code

year_var

The variable giving the calendar year

month_var

The variable giving the calendar month

Details

It is expected that the metric variable is an ordered factor prior to the creation of the long tables.

See Also

ann_tab_long, factor_apportioned, factor_prior_hc

Examples

library(dplyr)
data(line_listing)
line_listing <- line_listing %>%
  mutate(cyear = format(specimen_date, "%Y"),
    cmonth = date_to_cmonth(specimen_date),
    prior_hc = factor(prior_hc))

mo_tab_long(dat = line_listing, collection_var = collection,
  org_var = reporting_organisation_code,
  metric_var = prior_hc,
  year_var = cyear, month_var = cmonth
  )

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