Lubbock County

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

lubbock <- read_excel("data-raw/LubbockCounty.xlsx")
Warning: Coercing text to numeric in A1016 / R1016C1: '2018011602'
lubbock |> glimpse()
Rows: 5,937
Columns: 6
$ `1`           <dbl> 2.018e+09, 2.018e+09, 2.018e+09, 2.018e+09, 2.018e+09, 2…
$ `2`           <dbl> 198683, 159828, 176378, 150934, 158861, 137255, 193295, …
$ name          <chr> "ROBISON, DMOREA Q", "RAMIREZ, SIERRA", "MOSES, XAVIER J…
$ date_arrest   <chr> "2018-01-01", "2018-01-02", "2018-01-02", "2018-01-03", …
$ date_released <chr> "2018-03-02", "2018-01-06", "2018-01-29", "2018-01-03", …
$ agency_arrest <chr> "LPD-Rampy, Lloyd Brent", "LSO-MCGLONE,  KRISTINA HOPE",…

Cleaning

Just removing first two columns and making dates actual date types.

lubbock_clean <- lubbock |> select( 
  -"1",
  -"2",
  -date_released
) |> mutate(
  date_arrest = ymd(date_arrest)
) |> cbind(datetime_arrest = NA, charges = NA, address_arrest = NA, age = NA, race = NA, sex = NA, ethnicity = NA)

lubbock_clean |> glimpse()
Rows: 5,937
Columns: 10
$ name            <chr> "ROBISON, DMOREA Q", "RAMIREZ, SIERRA", "MOSES, XAVIER…
$ date_arrest     <date> 2018-01-01, 2018-01-02, 2018-01-02, 2018-01-03, 2018-…
$ agency_arrest   <chr> "LPD-Rampy, Lloyd Brent", "LSO-MCGLONE,  KRISTINA HOPE…
$ datetime_arrest <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ charges         <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ address_arrest  <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
$ 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…

Export

lubbock_clean |> write_csv("data-processed/Lubbock-County.csv")