Skip to contents

Many TPS PSDP crime layers carry BOTH HOOD_158 (current) and HOOD_140 (historical 2014–2021) columns. Pick the version your analysis needs explicitly so the two schemes are not silently mixed across years.

Usage

morie_tps_resolve_hood_col(df, prefer = c("158", "140"), fallback = TRUE)

Arguments

df

A TPS crime data.frame.

prefer

Either "158" (current) or "140" (historical).

fallback

If TRUE (default), accept the other version when the preferred one is absent (with a warning). If FALSE, return NULL when the preferred version is missing.

Value

Character scalar (the chosen column name), or NULL if no suitable column is present.

Examples

df <- data.frame(OCC_YEAR = 2024L, HOOD_158 = "82", HOOD_140 = "82")
morie_tps_resolve_hood_col(df, prefer = "158")
#> [1] "HOOD_158"