Learn R Programming

baselinenowcast (version 0.2.0)

apply_reporting_structure: Apply reporting structure to generate a single retrospective reporting triangle

Description

This function applies a reporting structure to a truncated reporting triangle by setting observations to NA row by row from the bottom up based on the specified structure. It is the singular version of apply_reporting_structures().

Usage

apply_reporting_structure(
  truncated_reporting_triangle,
  structure = 1,
  validate = TRUE
)

Value

A single retrospective reporting triangle matrix with NAs in the appropriate positions.

Arguments

truncated_reporting_triangle

A single truncated reporting_triangle object. May or may not contain NAs.

structure

Integer or vector specifying the reporting structure. If integer, divides columns evenly by that integer (with last possibly truncated). If vector, the sum must not be greater than or equal to the number of columns. Default is 1 (standard triangular structure).

validate

Logical. If TRUE (default), validates the object. Set to FALSE only when called from functions that already validated.

See Also

Retrospective data generation functions apply_reporting_structures(), truncate_to_row(), truncate_to_rows()

Examples

Run this code
# Standard triangular structure (default)
rep_tri <- apply_reporting_structure(example_reporting_triangle)
rep_tri

# Ragged structure with 2 columns per delay period
rep_ragged <- apply_reporting_structure(example_reporting_triangle, 2)
rep_ragged

# Custom structure with explicit column counts
rep_custom <- apply_reporting_structure(example_reporting_triangle, c(1, 2))
rep_custom

Run the code above in your browser using DataLab