Skip to contents

Either supply dfs_by_year (named list mapping year string / integer to a data.frame) or df + year_col.

Usage

mrm_uof_yoy_change(
  dfs_by_year = NULL,
  df = NULL,
  year_col = NULL,
  count_col = NULL
)

Arguments

dfs_by_year

Named list of data.frames, names coerced to integer years.

df

A data.frame to be grouped by year_col.

year_col

Required when df is supplied.

count_col

Optional column to sum within each year (rows counted otherwise).

Value

Named list with years, counts, yoy_pct, change_point_year, mean_abs_yoy_pct.

Details

Change-point detection is the manual largest-absolute-difference heuristic (the R port does not require changepoint).

Examples

inc <- morie_datasets_corrections_uof_incidents()
str(mrm_uof_yoy_change(df = inc, year_col = "year"), max.level = 1)
#> List of 12
#>  $ title              : chr "MRM-UOF Year-on-Year Change"
#>  $ call               : chr "mrm_uof_yoy_change(n_years=1)"
#>  $ summary_lines      :List of 5
#>  $ warnings           : chr "Only 1 year(s); too few for change-point detection."
#>  $ interpretation     : chr "Series spans 1 year(s) (2023-2023) with a total of 50 incident(s). Year-on-year volatility is undefined. No cha"| __truncated__
#>  $ n                  : int 1
#>  $ years              : int 2023
#>  $ counts             : int 50
#>  $ yoy_pct            : num NA
#>  $ change_point_year  : int NA
#>  $ change_point_method: chr "none"
#>  $ mean_abs_yoy_pct   : num NA
#>  - attr(*, "class")= chr [1:3] "morie_mrm_uof_result" "morie_rich_result" "list"