One-call NYPD data + borough + precinct join
Source:R/datasets_nyc_nypd.R
morie_datasets_nyc_nypd_resolved.RdPhase 3AAA. Pulls a slice of any
morie_datasets_nyc_nypd_by_key()-resolvable dataset and
left-joins its borough + precinct foreign keys against the
bundled resolvers (morie_datasets_nyc_boroughs() +
morie_datasets_nyc_police_precincts()).
Arguments
- dataset_key
One of the keys in
morie_datasets_nyc_nypd_layers().- year
Optional year filter (server-side SoQL).
- max_features
Optional row cap. When
paginate = TRUEthis is the total cap across walked pages.- offline
If
TRUE(default), read the bundled fixture.- resource_id
Optional Socrata resource id override.
- mode
One of
"soda2"(default JSON resource endpoint) or"soda3"(SoQLqueryendpoint). 3AAA dual-mode dispatch.- paginate
Logical; if
TRUEandoffline = FALSE, walk SODA2$offsetinpage_sizechunks until exhausted ormax_featuresis reached. DefaultFALSE(single 1,000-row request, matching the historical pre-3OO behaviour).- page_size
Per-page row count when paginating (default 1,000, the unauthenticated SODA2 ceiling).
- max_pages
Safety net on paginated walks (default 200 -> up to 200,000 rows without an app_token).
- app_token
Optional Socrata API app token for higher rate limits; passed as the
X-App-Tokenheader.- resolvers
Character subset of
c("boro", "precinct")to join. Default joins both.
Details
Auto-detects the borough + precinct columns per dataset:
| NYPD dataset | boro column | precinct column |
| nypd_arrests_historic | arrest_boro (M/B/K/Q/S) | arrest_precinct |
| nypd_arrests_ytd | arrest_boro | arrest_precinct |
| nypd_complaint_historic | boro_nm (UPPER) | addr_pct_cd |
| nypd_complaint_ytd | boro_nm (UPPER) | addr_pct_cd |
| nypd_hate_crimes | patrol_borough_name | complaint_precinct_code |
| nypd_uof_incidents | (none directly; precinct only) | precinct |
Resolver columns prefixed boro_* + precinct_* to avoid
collisions. Left-join semantics (row count preserved).
Examples
df <- morie_datasets_nyc_nypd_resolved("nypd_arrests_ytd",
offline = TRUE)
names(df)
#> [1] "law_book" "ky_cd" "pd_cd"
#> [4] "arrest_precinct" "arrest_boro" "arrest_key"
#> [7] "arrest_date" "pd_desc" "ofns_desc"
#> [10] "law_code" "law_cat_cd" "jurisdiction_code"
#> [13] "age_group" "perp_sex" "perp_race"
#> [16] "x_coord_cd" "y_coord_cd" "latitude"
#> [19] "longitude" "geocoded_column" "boro_borocode"
#> [22] "boro_boroname" "boro_boro_nm" "boro_shape_area"
#> [25] "boro_shape_leng" "precinct_shape_leng" "precinct_shape_area"
#> [28] "offense_ofns_desc" "offense_pd_desc" "offense_law_cat_cd"
#> [31] "law_section" "law_book_name" "law_jurisdiction"