Howard 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

howard <- read_excel("data-raw/HowardCounty.xls")
New names:
• `` -> `...4`
howard |> glimpse()
Rows: 661
Columns: 8
$ date_arrest   <dttm> 2018-01-05, 2018-01-06, 2018-01-07, 2018-01-07, 2018-01…
$ name          <chr> "CHILDS, DEVONTAY TRAYVON", "HILGER, BRITTNEY JO", "CARR…
$ age           <dbl> 31, 28, 42, 24, 53, 57, 24, 46, 25, 46, 26, 50, 33, 27, …
$ ...4          <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
$ sex           <chr> "M", "F", "M", "M", "F", "M", "M", "F", "M", "M", "F", "…
$ time_arrest   <dttm> 1899-12-31 09:37:00, 1899-12-31 02:23:00, 1899-12-31 11…
$ agency_arrest <chr> "GLASS", "BSPD", "BSPD", "BSPD", "BSPD", "BSPD", "HCSO",…
$ charges       <chr> "POSS MARIJ <2OZ", "MTRP/POSS MARIJ <2OZ", "BOB/POSS MAR…

Clean Columns

putting together the date and time and getting rid of the blank column

howard_col <- howard |> mutate(
  datetime_arrest = paste(date_arrest, paste(hour(time_arrest), minute(time_arrest), second(time_arrest), sep = ":"))
)

howard_clean <- howard_col |> mutate(
  datetime_arrest = ymd_hms(datetime_arrest)
) |> select(
  -time_arrest,
  -...4
) |> cbind(ethnicity = NA, race = NA, address_arrest = NA)

howard_clean |> glimpse()
Rows: 661
Columns: 10
$ date_arrest     <dttm> 2018-01-05, 2018-01-06, 2018-01-07, 2018-01-07, 2018-…
$ name            <chr> "CHILDS, DEVONTAY TRAYVON", "HILGER, BRITTNEY JO", "CA…
$ age             <dbl> 31, 28, 42, 24, 53, 57, 24, 46, 25, 46, 26, 50, 33, 27…
$ sex             <chr> "M", "F", "M", "M", "F", "M", "M", "F", "M", "M", "F",…
$ agency_arrest   <chr> "GLASS", "BSPD", "BSPD", "BSPD", "BSPD", "BSPD", "HCSO…
$ charges         <chr> "POSS MARIJ <2OZ", "MTRP/POSS MARIJ <2OZ", "BOB/POSS M…
$ datetime_arrest <dttm> 2018-01-05 09:37:00, 2018-01-06 02:23:00, 2018-01-07 …
$ ethnicity       <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…
$ address_arrest  <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…

Export

howard_clean |> write_csv("data-processed/Howard-County.csv")