Mirrors morie_tps_csi_per_year but groups by
neighbourhood ID rather than fiscal year. Population is not divided
in here because TPS open data does not ship a per-ward population
table; callers are expected to merge in the City of Toronto Open
Data NeighbourhoodCrimeRates per-ward population for per-capita
rates. Returns the un-normalised weighted sum + total count.
Usage
morie_tps_csi_per_neighbourhood(
counts_per_hood,
variant = c("total", "violent"),
weights = NULL
)Examples
set.seed(1)
counts <- data.frame(HOOD_158 = rep(sprintf("%03d", 1:4), 2),
category = rep(c("Assault", "Robbery"), each = 4),
count = rpois(8, 50))
res <- try(morie_tps_csi_per_neighbourhood(counts))
if (!inherits(res, "try-error")) str(res, max.level = 1)
#> 'data.frame': 4 obs. of 3 variables:
#> $ HOOD_158 : chr "001" "002" "003" "004"
#> $ raw_weighted_sum: num 28722 38746 39779 38398
#> $ total_count : num 84 112 113 106
