Skip to contents

This method takes a data.frame containing case counts indexed by reference date and report date and creates a reporting_triangle object. See as_reporting_triangle.matrix() for other data input options.

Usage

# S3 method for class 'data.frame'
as_reporting_triangle(
  data,
  delays_unit = "days",
  reference_date = "reference_date",
  report_date = "report_date",
  count = "count",
  ...
)

Arguments

data

Data.frame in a long tidy format with counts by reference date and report date. Must contain the following columns: . - Column of type date or character with the dates of the primary event occurrence (reference date).

  • Column of type date or character with the dates of report of the primary event (report_date).

  • Column of numeric or integer indicating the new confirmed counts pertaining to that reference and report date (count). Additional columns can be included but will not be used. The input dataframe for this function must contain only a single strata, there can be no repeated reference dates and report dates.

delays_unit

Character string specifying the temporal granularity of the delays. Options are "days", "weeks", "months", "years". Default is "days".

reference_date

Character string indicating the name of the column which represents the reference date, or the date of the primary event occurrence.

report_date

Character string indicating the name of the column which represents the date the primary event was reported.

count

Character string indicating the name of the column containing the number of incident cases on each reference and report date.

...

Additional arguments not used.

Value

A reporting_triangle object

Examples

# Filter to reasonable max_delay for faster example
data_as_of_df <- syn_nssp_df[
  syn_nssp_df$report_date <= "2026-04-01" &
  (syn_nssp_df$report_date - syn_nssp_df$reference_date) <= 25,
]
as_reporting_triangle(data = data_as_of_df)
#>  Using max_delay = 25 from data
#> Reporting Triangle
#> Delays unit: days
#> Reference dates: 2025-10-25 to 2026-04-01
#> Max delay: 25
#> Structure: 1
#> 
#> Showing last 10 of 159 rows
#> Showing first 10 of 26 columns
#> 
#>              0   1  2  3  4  5  6  7  8  9
#> 2026-03-23 210 131 34 50 35 12  1 25 20  6
#> 2026-03-24 221  96 22 10 13  6  0  5  9 NA
#> 2026-03-25 291 129 17 26 42 29 23 25 NA NA
#> 2026-03-26 179  96 22 50  9  8 18 NA NA NA
#> 2026-03-27 284  40 41 54 28 12 NA NA NA NA
#> 2026-03-28 217  78 46 14 39 NA NA NA NA NA
#> 2026-03-29 336 161 62 13 NA NA NA NA NA NA
#> 2026-03-30 296  53 55 NA NA NA NA NA NA NA
#> 2026-03-31 210 108 NA NA NA NA NA NA NA NA
#> 2026-04-01 236  NA NA NA NA NA NA NA NA NA
#> 
#> Use print(x, n_rows = NULL, n_cols = NULL) to see all data