# Load packagespacman::p_load(here, httr2, tidyverse)# Create the directory for the original downloaded datadir.create(here("data", "raw"), recursive =TRUE, showWarnings =FALSE)# Download the original datarequest("https://mpjashby.github.io/crimemappingdata/medellin_homicides.csv") |>req_perform(path =here("data", "raw", "medellin_homicides.csv"))
<httr2_response>
GET https://mpjashby.github.io/crimemappingdata/medellin_homicides.csv
Status: 200 OK
Content-Type: text/csv
Body: On disk '/Users/mattashby/Documents/Crime Mapping Book/data/raw/medellin_homicides.csv' (702486 bytes)
ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
Rows: 9360 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ";"
chr (2): sexo, modalidad
dbl (3): longitud, latitud, edad
dttm (1): fecha_hecho
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Count number of homicides in February 2019homicide_count <- medellin_homicides |>filter(year(fecha_hecho) ==2019, month(fecha_hecho) ==2) |>nrow()
There were 50 homicides recorded in February 2019.