Skip to contents

Fetch a NYC OpenData Socrata dataset by ID

Fetch a Chicago Open Data Socrata dataset by ID

Usage

morie_datasets_nyc_socrata_by_id(soda_id, limit = 1000L)

morie_datasets_chicago_socrata_by_id(soda_id, limit = 1000L)

Arguments

soda_id

4-4 Socrata resource ID.

limit

Page size.

Value

A data.frame of records.

A data.frame of the requested dataset (a 0-row typed frame when the data is unavailable offline).

Examples

# \donttest{
# NYPD arrests dataset (SODA id verified live 2026-07)
df <- try(morie_datasets_nyc_socrata_by_id("8h9b-rp9u", limit = 5L))
if (!inherits(df, "try-error")) head(df)
#>   arrest_key             arrest_date pd_cd                        pd_desc ky_cd
#> 1  318178739 2025-12-31T00:00:00.000   114            OBSTR BREATH/CIRCUL   344
#> 2  318172848 2025-12-31T00:00:00.000   922 TRAFFIC,UNCLASSIFIED MISDEMEAN   348
#> 3  318178340 2025-12-31T00:00:00.000   101                      ASSAULT 3   344
#> 4  318194573 2025-12-31T00:00:00.000   244  BURGLARY,UNCLASSIFIED,UNKNOWN   107
#> 5  318203921 2025-12-31T00:00:00.000   705             FORGERY,ETC.-MISD.   358
#>                      ofns_desc   law_code law_cat_cd arrest_boro
#> 1 ASSAULT 3 & RELATED OFFENSES PL 1211100          M           M
#> 2     VEHICLE AND TRAFFIC LAWS VTL0511001          M           B
#> 3 ASSAULT 3 & RELATED OFFENSES PL 1200001          M           K
#> 4                     BURGLARY PL 1402501          F           M
#> 5     OFFENSES INVOLVING FRAUD PL 1702000          M           K
#>   arrest_precinct jurisdiction_code age_group perp_sex      perp_race
#> 1              28                 0     25-44        M WHITE HISPANIC
#> 2              48                 0     25-44        M        UNKNOWN
#> 3              71                 0    (null)   (null)          BLACK
#> 4              33                 0     25-44        M BLACK HISPANIC
#> 5              81                 0     25-44        M BLACK HISPANIC
#>   x_coord_cd y_coord_cd    latitude    longitude :@computed_region_efsh_h5xi
#> 1     998296     234474    40.81025   -73.949261                       12424
#> 2    1015670     251490   40.856911   -73.886418                       10936
#> 3    1003011     180203   40.661281   -73.932379                       16866
#> 4    1002253     247662   40.846442   -73.934929                       13091
#> 5    1005166     186675 40.67903176 -73.92459115                       13516
#>   :@computed_region_f5dn_yrer :@computed_region_yeji_bk3q
#> 1                          18                           4
#> 2                          35                           5
#> 3                          17                           2
#> 4                          47                           4
#> 5                          69                           2
#>   :@computed_region_92fq_4b7q :@computed_region_sbqj_enih
#> 1                          36                          18
#> 2                          22                          31
#> 3                          17                          44
#> 4                          39                          21
#> 5                          17                          52
# }
# \donttest{
# Chicago crimes dataset (SODA id verified live 2026-07)
df <- try(morie_datasets_chicago_socrata_by_id("ijzp-q8t2", limit = 5L))
if (!inherits(df, "try-error")) head(df)
#>         id case_number                    date                  block iucr
#> 1 14352678    JK443846 2026-10-08T00:00:00.000    029XX N ASHLAND AVE 0860
#> 2 14358733    JK451298 2026-10-08T00:00:00.000 002XX N CALIFORNIA AVE 0820
#> 3 14353116    JK444367 2026-10-08T00:00:00.000 012XX E HYDE PARK BLVD 0281
#> 4 14352257    JK443434 2026-10-08T00:00:00.000     050XX S ARCHER AVE 1310
#> 5 14351774    JK442735 2026-10-08T00:00:00.000     057XX S KENTON AVE 0486
#>              primary_type             description location_description arrest
#> 1                   THEFT            RETAIL THEFT     DEPARTMENT STORE   TRUE
#> 2                   THEFT          $500 AND UNDER               STREET  FALSE
#> 3 CRIMINAL SEXUAL ASSAULT          NON-AGGRAVATED            APARTMENT  FALSE
#> 4         CRIMINAL DAMAGE             TO PROPERTY              LIBRARY   TRUE
#> 5                 BATTERY DOMESTIC BATTERY SIMPLE            APARTMENT  FALSE
#>   domestic beat district ward community_area fbi_code x_coordinate y_coordinate
#> 1    FALSE 1931      019   32              6       06      1165142      1919763
#> 2    FALSE 1222      012   27             27       06         <NA>         <NA>
#> 3    FALSE 0234      002    4             41       02      1185235      1871436
#> 4    FALSE 0815      008   14             57       14      1149711      1870739
#> 5     TRUE 0813      008   13             62      08B      1146721      1866169
#>   year              updated_on     latitude     longitude
#> 1 2026 2026-10-15T15:51:00.000 41.935432921 -87.668504341
#> 2 2026 2026-10-15T15:51:00.000         <NA>          <NA>
#> 3 2026 2026-10-15T15:51:00.000 41.802370227  -87.59618765
#> 4 2026 2026-10-15T15:51:00.000 41.801219701 -87.726488031
#> 5 2026 2026-10-15T15:51:00.000 41.788736303 -87.737569739
#>   :@computed_region_awaf_s7ux :@computed_region_6mkv_f3dw
#> 1                          16                        4449
#> 2                        <NA>                        <NA>
#> 3                           1                       21192
#> 4                          49                       22248
#> 5                          23                       21867
#>   :@computed_region_vrxf_vc4k :@computed_region_bdys_3d7i
#> 1                          57                         712
#> 2                        <NA>                        <NA>
#> 3                           8                         412
#> 4                          54                         697
#> 5                          60                         773
#>   :@computed_region_43wa_7qmu :@computed_region_rpca_8um6
#> 1                          40                          22
#> 2                        <NA>                        <NA>
#> 3                          10                          10
#> 4                           8                          56
#> 5                          15                          58
#>   :@computed_region_d9mm_jgwp :@computed_region_d3ds_rm58
#> 1                           5                         173
#> 2                        <NA>                        <NA>
#> 3                          24                         122
#> 4                          13                         105
#> 5                          13                         271
#>   :@computed_region_8hcu_yrd4
#> 1                          32
#> 2                        <NA>
#> 3                           9
#> 4                          14
#> 5                          13
# }
# \donttest{
# Chicago crimes dataset (SODA id verified live 2026-07)
df <- try(morie_datasets_chicago_socrata_by_id("ijzp-q8t2", limit = 5L))
if (!inherits(df, "try-error")) head(df)
#>         id case_number                    date                  block iucr
#> 1 14352678    JK443846 2026-10-08T00:00:00.000    029XX N ASHLAND AVE 0860
#> 2 14358733    JK451298 2026-10-08T00:00:00.000 002XX N CALIFORNIA AVE 0820
#> 3 14353116    JK444367 2026-10-08T00:00:00.000 012XX E HYDE PARK BLVD 0281
#> 4 14352257    JK443434 2026-10-08T00:00:00.000     050XX S ARCHER AVE 1310
#> 5 14351774    JK442735 2026-10-08T00:00:00.000     057XX S KENTON AVE 0486
#>              primary_type             description location_description arrest
#> 1                   THEFT            RETAIL THEFT     DEPARTMENT STORE   TRUE
#> 2                   THEFT          $500 AND UNDER               STREET  FALSE
#> 3 CRIMINAL SEXUAL ASSAULT          NON-AGGRAVATED            APARTMENT  FALSE
#> 4         CRIMINAL DAMAGE             TO PROPERTY              LIBRARY   TRUE
#> 5                 BATTERY DOMESTIC BATTERY SIMPLE            APARTMENT  FALSE
#>   domestic beat district ward community_area fbi_code x_coordinate y_coordinate
#> 1    FALSE 1931      019   32              6       06      1165142      1919763
#> 2    FALSE 1222      012   27             27       06         <NA>         <NA>
#> 3    FALSE 0234      002    4             41       02      1185235      1871436
#> 4    FALSE 0815      008   14             57       14      1149711      1870739
#> 5     TRUE 0813      008   13             62      08B      1146721      1866169
#>   year              updated_on     latitude     longitude
#> 1 2026 2026-10-15T15:51:00.000 41.935432921 -87.668504341
#> 2 2026 2026-10-15T15:51:00.000         <NA>          <NA>
#> 3 2026 2026-10-15T15:51:00.000 41.802370227  -87.59618765
#> 4 2026 2026-10-15T15:51:00.000 41.801219701 -87.726488031
#> 5 2026 2026-10-15T15:51:00.000 41.788736303 -87.737569739
#>   :@computed_region_awaf_s7ux :@computed_region_6mkv_f3dw
#> 1                          16                        4449
#> 2                        <NA>                        <NA>
#> 3                           1                       21192
#> 4                          49                       22248
#> 5                          23                       21867
#>   :@computed_region_vrxf_vc4k :@computed_region_bdys_3d7i
#> 1                          57                         712
#> 2                        <NA>                        <NA>
#> 3                           8                         412
#> 4                          54                         697
#> 5                          60                         773
#>   :@computed_region_43wa_7qmu :@computed_region_rpca_8um6
#> 1                          40                          22
#> 2                        <NA>                        <NA>
#> 3                          10                          10
#> 4                           8                          56
#> 5                          15                          58
#>   :@computed_region_d9mm_jgwp :@computed_region_d3ds_rm58
#> 1                           5                         173
#> 2                        <NA>                        <NA>
#> 3                          24                         122
#> 4                          13                         105
#> 5                          13                         271
#>   :@computed_region_8hcu_yrd4
#> 1                          32
#> 2                        <NA>
#> 3                           9
#> 4                          14
#> 5                          13
# }