Slaton 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)
library(eeptools)

Import

Same process as before

slaton <- read_excel("data-raw/SlatonCity.xls")

slaton |> glimpse()
Rows: 34
Columns: 7
$ date_arrest    <chr> "3/25/2018", "4/6/2018", "5/8/2018", "6/3/2018", "6/14/…
$ name           <chr> "HERNANDEZ, TAMY", "GARCIA, FRANK  JR", "BROOME, KEVIN"…
$ DOB            <chr> "6/29/1981", "4/24/2000", "8/10/1981", "4/12/1983", "7/…
$ sex            <chr> "F", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", …
$ race           <chr> "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", …
$ address_arrest <chr> "800 BLK S 13TH STREET", "1000 BLK S 11TH STREET", "600…
$ charges        <chr> "POSS MARIJUANA <= 2 OZ", "POSSESSION OF MARIJUANA < 2 …

Clean

Just need to change dates to dttm types.

slaton_clean <- slaton |> mutate(
  date_arrest = mdy(date_arrest),
  DOB = mdy(DOB),
  age = age_calc(DOB, enddate = date_arrest,units = "years", precise = TRUE)) |> select(
    -DOB
  ) |> cbind(datetime_arrest = NA, agency_arrest = NA, ethnicity = NA)

slaton_clean |> glimpse()
Rows: 34
Columns: 10
$ date_arrest     <date> 2018-03-25, 2018-04-06, 2018-05-08, 2018-06-03, 2018-…
$ name            <chr> "HERNANDEZ, TAMY", "GARCIA, FRANK  JR", "BROOME, KEVIN…
$ sex             <chr> "F", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M",…
$ race            <chr> "W", "W", "W", "W", "W", "W", "W", "W", "W", "W", "W",…
$ address_arrest  <chr> "800 BLK S 13TH STREET", "1000 BLK S 11TH STREET", "60…
$ charges         <chr> "POSS MARIJUANA <= 2 OZ", "POSSESSION OF MARIJUANA < 2…
$ age             <dbl> 36.73699, 17.94795, 36.74247, 35.14247, 24.92603, 26.5…
$ datetime_arrest <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…
$ ethnicity       <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…

Export

slaton_clean |> write_csv("data-processed/Slaton-City.csv")