Skip to contents

NYC OpenData does NOT publish a standalone NYPD-offense-code table; the canonical mapping is implicit in the (ky_cd, ofns_desc, pd_cd, pd_desc, law_cat_cd) tuples carried by every Arrests / Complaints record. This bundled fixture was derived by running a $group query on the NYPD Arrests YTD feed (uip8-fykc) at fixture-creation time, giving the 246 distinct offense tuples currently in active use. Mirrors the chicago_iucr_codes pattern (3UU).

Usage

morie_datasets_nyc_nypd_offense_codes(max_features = NULL)

Arguments

max_features

Optional row cap.

Value

A data.frame with 246 rows x 5 cols.

Details

Schema (all character):

ky_cd

3-digit Key Code (top-level offense category).

ofns_desc

Description for ky_cd (NYPD-truncated to 30 chars; e.g. "MURDER & NON-NEGL. MANSLAUGHTE").

pd_cd

3-digit Penal-Detailed code (subcategory).

pd_desc

Description for pd_cd (same truncation).

law_cat_cd

Penal classification: "F" felony / "M" misdemeanor / "V" violation / "I" infraction / (blank).

The string descriptions ARE truncated at 30 chars in the upstream NYPD feeds; this is NOT a morie processing bug – it's how NYPD's NYS DCJS warehouse stores them. PRs welcome to add a parallel pd_desc_full column once a canonical un-truncated source is identified.

Refreshing the fixture:

# Re-derive when the YTD feed adds new offense tuples (rare):
#   curl "https://data.cityofnewyork.us/resource/uip8-fykc.json
#         ?$select=ky_cd,ofns_desc,pd_cd,pd_desc,law_cat_cd
#         &$group=ky_cd,ofns_desc,pd_cd,pd_desc,law_cat_cd
#         &$order=ky_cd,pd_cd&$limit=10000"
# then write to inst/extdata/nyc_nypd_offense_codes.csv.

Examples

codes <- morie_datasets_nyc_nypd_offense_codes()
subset(codes, ky_cd == "104")  # all RAPE subcategories
#>   ky_cd ofns_desc pd_cd pd_desc law_cat_cd
#> 4   104      RAPE   153  RAPE 3          F
#> 5   104      RAPE   155  RAPE 2          F
#> 6   104      RAPE   157  RAPE 1          F