
Side-by-side year-over-year panel across TPS categories
Source:R/tps_crime.R
morie_tps_yoy_panel.RdFor each named TPS category in dfs, groups by the dataset's
year column (OCC_YEAR preferred, REPORT_YEAR
fallback), restricts to plausible years (1990-2030), and joins all
series column-wise into a single panel of incident counts.
Examples
set.seed(1)
df <- data.frame(OCC_YEAR = rep(2014:2023, each = 30),
OCC_MONTH = sample(month.name, 300, TRUE),
HOOD_158 = sample(sprintf("%03d", 1:20), 300, TRUE),
LAT_WGS84 = runif(300, 43.6, 43.8),
LONG_WGS84 = runif(300, -79.5, -79.2))
dfs <- list(a = df, b = df)
res <- try(morie_tps_yoy_panel(dfs))
if (!inherits(res, "try-error")) str(res, max.level = 1)
#> List of 8
#> $ title : chr "TPS -- year-over-year panel (cross-category)"
#> $ call : chr "morie_tps_yoy_panel(dfs)"
#> $ summary_lines :List of 3
#> $ tables :List of 1
#> $ warnings : chr(0)
#> $ interpretation: chr "One column per TPS category, one row per fiscal year, cell = annual incident count. Suitable for side-by-side "| __truncated__
#> $ payload :List of 3
#> $ sections : list()
#> - attr(*, "class")= chr [1:3] "morie_tps_result" "morie_rich_result" "list"