
Load a TPS incident dataset for the statistical-physics suite
Source:R/tps_statphysics.R
morie_tps_load_tps_dataset.RdPortable dataset bridge: uses a local project export via
morie_tps_load_dataset() when one exists, otherwise fetches the
category live from the public Toronto Police Service ArcGIS portal
via morie_fetch_tps() (cached under cache_dir). No private
infrastructure is involved, so results reproduce on any machine.
Arguments
- category
TPS category name (see
morie_tps_layer_urls()).- nrows
Optional row cap applied after load.
- cache_dir
Cache directory for the live fetch; defaults to a session temporary directory.
Examples
# \donttest{
try(head(morie_tps_load_tps_dataset("Homicides", nrows = 100)))
#> morie_tps: no local TPS cache for 'Homicides'; using the bundled sample from rmorie. Fetch the full export with morie_tps_fetch_category().
#> OBJECTID EVENT_UNIQUE_ID OCC_DATE OCC_YEAR OCC_MONTH OCC_DAY
#> 1 1 GO-PSDP-SYNTH-HOM-001 2023/04/12 00:00:00 2023 4 12
#> 2 2 GO-PSDP-SYNTH-HOM-002 2023/09/03 00:00:00 2023 9 3
#> 3 3 GO-PSDP-SYNTH-HOM-003 2024/01/20 00:00:00 2024 1 20
#> 4 4 GO-PSDP-SYNTH-HOM-004 2024/07/15 00:00:00 2024 7 15
#> 5 5 GO-PSDP-SYNTH-HOM-005 2025/02/28 00:00:00 2025 2 28
#> OCC_DOW OCC_DOY DIVISION HOMICIDE_TYPE HOOD_158 NEIGHBOURHOOD_158
#> 1 Wednesday 102 D52 Shooting 168 Downtown Yonge East
#> 2 Sunday 246 D14 Stabbing 82 Niagara
#> 3 Saturday 20 D31 Shooting 73 Moss Park
#> 4 Monday 197 D55 Other 1 West Humber-Clairville
#> 5 Friday 59 D14 Shooting 163 Fort York-Liberty Village
#> HOOD_140 NEIGHBOURHOOD_140 LONG_WGS84 LAT_WGS84 x y
#> 1 75 Church-Yonge Corridor (75) -79.3793 43.6532 -79.3793 43.6532
#> 2 82 Niagara (82) -79.4029 43.6478 -79.4029 43.6478
#> 3 73 Moss Park (73) -79.3705 43.6555 -79.3705 43.6555
#> 4 1 West Humber-Clairville (1) -79.5800 43.7400 -79.5800 43.7400
#> 5 82 Niagara (82) -79.3832 43.6426 -79.3832 43.6426
# }