Snyder City

Setup

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.3     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)

Attaching package: 'janitor'

The following objects are masked from 'package:stats':

    chisq.test, fisher.test
library(readxl)
library(lubridate)

Import

Same process as before

snyder <- read_excel("data-raw/SnyderCity.xls")

snyder |> glimpse()
Rows: 75
Columns: 7
$ officer         <chr> "ROJAS, MAESON", "ROJAS, MAESON", "ROJAS, MAESON", "RE…
$ datetime_arrest <chr> "01/28/2018 03:06", "03/10/2018 01:20", "03/10/2018 01…
$ charge_desc     <chr> "POSS MARIJ <2OZ MB/DRIVING WHILE LIC SUSPENDED/INVALI…
$ address_arrest  <chr> "2800 BLOCK AVE F", "2800 COLLEGE AVENUE", "2800 COLLE…
$ city_zip        <chr> "SNYDER, TX 79549", "SNYDER, TX 79549", "SNYDER, TX 79…
$ name            <chr> "BREWSTER, KENDALL KAY", "FEASTER, BRIGHTON", "MORENO,…
$ charges         <chr> "DRIVING WHILE LIC  SUSPENDED/INVALID M*, POSS MARIJ <…

Clean

snyder_clean <- snyder |> mutate(
  datetime_arrest = mdy_hm(datetime_arrest),
  date_arrest = date(datetime_arrest)
) |> select(
  -officer,
  -charge_desc,
  -city_zip
) |> cbind(age = NA, race = NA, sex = NA, ethnicity = NA, agency_arrest = NA)

snyder_clean |> glimpse()
Rows: 75
Columns: 10
$ datetime_arrest <dttm> 2018-01-28 03:06:00, 2018-03-10 01:20:00, 2018-03-10 …
$ address_arrest  <chr> "2800 BLOCK AVE F", "2800 COLLEGE AVENUE", "2800 COLLE…
$ name            <chr> "BREWSTER, KENDALL KAY", "FEASTER, BRIGHTON", "MORENO,…
$ charges         <chr> "DRIVING WHILE LIC  SUSPENDED/INVALID M*, POSS MARIJ <…
$ date_arrest     <date> 2018-01-28, 2018-03-10, 2018-03-10, 2018-03-19, 2018-…
$ age             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ race            <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ sex             <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ ethnicity       <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ agency_arrest   <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…

Export

snyder_clean |> write_csv("data-processed/Snyder-City.csv")