Skip to contents

Cake-cutting in the REVERSE direction. Given a data.frame of per- current-hood counts (one row per hood_158, one or more numeric count columns), sums across the 158-children of each 140 weighted by pct_158_in_140 / 100. For 1:1 hoods the count passes through. For splits the children's counts are summed exactly (each child has pct_158_in_140 == 100 for clean cake-cuts).

Usage

morie_tps_aggregate_158_to_140(
  df,
  hood_158_col = "HOOD_158",
  count_cols = NULL,
  crosswalk = NULL
)

Arguments

df

A data.frame keyed on a 158-hood column.

hood_158_col

Name of the 158-hood column. Default "HOOD_158".

count_cols

Character vector of numeric count columns. By default every numeric column except hood_158_col.

crosswalk

Optional pre-loaded crosswalk.

Value

A data.frame with one row per 140-hood, columns hood_140, name_140, and the summed count_cols.

Details

Unlike morie_tps_disaggregate_140_to_158(), this requires NO uniform-density assumption when the source is a clean cake-cut – the partition is exhaustive and disjoint by construction. The only lossy case is the split+merge edge (one Willowdale East sliver in the bundled OT data); the function handles it via the pct_158_in_140 weights regardless.

Examples

df <- data.frame(HOOD_158 = c("167", "168", "001"),
                 incidents = c(40, 60, 42))
morie_tps_aggregate_158_to_140(df)
#>   hood_140                   name_140 incidents
#> 1      001 West Humber-Clairville (1)        42
#> 2      075 Church-Yonge Corridor (75)       100