Skip to contents

Phase 3VV+. Pulls a slice of morie_datasets_chicago_crime() and left-joins each of its five canonical foreign keys against the matching resolver dataset shipped in morie:

Usage

morie_datasets_chicago_crime_resolved(
  year = NULL,
  max_features = NULL,
  offline = TRUE,
  mode = c("soda2", "soda3"),
  paginate = FALSE,
  page_size = 1000L,
  max_pages = 200L,
  app_token = NULL,
  resolvers = c("ward", "community_area", "beat", "district", "iucr")
)

Arguments

year

Integer or NULL; server-side year filter.

max_features

Integer or NULL; cap on returned rows. When paginate = TRUE this is the total cap across all walked pages.

offline

Logical; if TRUE, return the bundled synthetic frame.

mode

One of "soda2" (default) or "soda3". Selects the API path for live mode:

  • "soda2" -> /resource/<id>.json?$where=... via .morie_dataset_socrata_fetch() (URL-param SoQL grammar).

  • "soda3" -> /api/v3/views/<id>/query.json?query=SELECT ... via .morie_dataset_soda3_query() (full SoQL passthrough). Both modes return the same 22-column schema; SODA3 is required when a derived/map view is involved (none here, but available for parity with morie_datasets_chicago_crime_map()) and for the canonical "single SoQL string" experience.

paginate

Logical; if TRUE and offline = FALSE, walk pagination in page_size chunks. SODA2 uses $offset; SODA3 uses LIMIT page_size OFFSET m baked into the SoQL.

page_size

Integer; per-page row count when paginate = TRUE. Default 1,000 (the unauthenticated SODA2 ceiling).

max_pages

Integer; safety net on paginate = TRUE walks (default 200 -> up to 200,000 rows without an app_token).

app_token

Optional Socrata app token (SODA3 only – sent as the X-App-Token header; ignored under mode = "soda2").

resolvers

Character subset of the 5 resolver names to join. Default joins all 5. Pass a shorter vector to skip specific joins (e.g. "iucr" only).

Value

A wide data.frame: crime columns first, then the joined resolver columns with their canonical prefixes.

Details

crime fieldresolverjoin key
beatmorie_datasets_chicago_police_beats()beat == beat_num
districtmorie_datasets_chicago_police_districts()district == dist_num
wardmorie_datasets_chicago_wards()ward == ward
community_areamorie_datasets_chicago_community_areas()community_area == area_numbe
iucrmorie_datasets_chicago_iucr_codes()iucr == iucr

The resolvers are loaded in offline mode (they're all bundled + small), so this analyzer only touches the network for the crime pull itself. Resolver columns are prefixed with the source name (ward_*, community_*, beat_*, district_*, iucr_*) to avoid collisions with the crime schema.

Both mode = "soda2" and mode = "soda3" are honoured for the crime fetch, matching the dual-API design from 3VV+.

Examples

df <- morie_datasets_chicago_crime_resolved(
  offline = TRUE,
  max_features = 5L,
  resolvers = c("ward", "iucr"))
#> Warning: morie_datasets_chicago_crime(offline=TRUE): using the bundled synthetic chicago_crime frame. This is a toy dataset with the documented schema but random data; do not interpret outputs as findings about the real population.
names(df)
#>  [1] "iucr"                       "ward"                      
#>  [3] "id"                         "case_number"               
#>  [5] "date"                       "block"                     
#>  [7] "primary_type"               "description"               
#>  [9] "location_description"       "arrest"                    
#> [11] "domestic"                   "beat"                      
#> [13] "district"                   "community_area"            
#> [15] "fbi_code"                   "x_coordinate"              
#> [17] "y_coordinate"               "year"                      
#> [19] "updated_on"                 "latitude"                  
#> [21] "longitude"                  "location"                  
#> [23] "ward_shape_leng"            "ward_shape_area"           
#> [25] "iucr_primary_description"   "iucr_secondary_description"
#> [27] "iucr_index_code"            "iucr_active"