Replace the lower right triangle of the matrix with NAs
Source:R/utils.R
      replace_lower_right_with_NA.RdReplace the lower right triangle of the matrix with NAs
Examples
# Define a reporting triangle with zeros
triangle_w_zeros <- matrix(
  c(
    1, 3, 5, 7, 9,
    4, 7, 8, 0, 12,
    9, 10, 0, 0, 15,
    3, 0, 0, 0, 0,
    6, 2, 0, 0, 0
  ),
  nrow = 5,
  byrow = TRUE
)
# Standard triangular structure (default)
rep_tri <- replace_lower_right_with_NA(triangle_w_zeros)
rep_tri
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    3    5    7    9
#> [2,]    4    7    8    0   NA
#> [3,]    9   10    0   NA   NA
#> [4,]    3    0   NA   NA   NA
#> [5,]    6   NA   NA   NA   NA
# Ragged structure with 2 columns per delay period
rep_ragged <- replace_lower_right_with_NA(triangle_w_zeros, 2)
rep_ragged
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    3    5    7    9
#> [2,]    4    7    8    0   12
#> [3,]    9   10    0    0   15
#> [4,]    3    0    0    0   NA
#> [5,]    6    2   NA   NA   NA
# Custom structure with explicit column counts
rep_custom <- replace_lower_right_with_NA(triangle_w_zeros, c(1, 2, 1))
rep_custom
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    3    5    7    9
#> [2,]    4    7    8    0   12
#> [3,]    9   10    0    0   NA
#> [4,]    3    0    0   NA   NA
#> [5,]    6   NA   NA   NA   NA