Setup

Get the tidyverse library all up in this file!

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.4     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   2.0.1     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()

Import Data

Import our cleaned and filtered data into this notebook

#import from processed folder
tx <- read_rds("data-processed/01-leso-tx.rds")

# glimpse our data
tx %>% glimpse()
## Rows: 7,407
## Columns: 9
## $ state             <chr> "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX", "TX"…
## $ agency_name       <chr> "ABERNATHY POLICE DEPT", "ABERNATHY POLICE DEPT", "A…
## $ item_name         <chr> "PISTOL,CALIBER .45,AUTOMATIC", "PISTOL,CALIBER .45,…
## $ quantity          <dbl> 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ ui                <chr> "Each", "Each", "Each", "Each", "Each", "Each", "Eac…
## $ acquisition_value <dbl> 58.71, 58.71, 58.71, 58.71, 58.71, 749.00, 749.00, 3…
## $ ship_date         <dttm> 2011-11-03, 2011-11-03, 2011-11-03, 2011-11-03, 201…
## $ station_type      <chr> "State", "State", "State", "State", "State", "State"…
## $ total_value       <dbl> 58.71, 58.71, 58.71, 58.71, 58.71, 749.00, 749.00, 1…

Agency totals

For each agency in Texas, find the summed quantity and summed total value of the equipment they received.

tx_quant_totals <- tx %>% 
  group_by(agency_name) %>% # group by agency
  summarize(
    summed_quantity = sum(quantity),
    summed_total_val = sum(total_value)
  ) %>% # sum total quantity and total values
  arrange(summed_total_val %>% desc()) # Arrange by dept with most total val

#peek at results
tx_quant_totals

Texas total gifts

Take a closer look at how much value went to Texas overall

tx %>% 
  summarize(
    summed_quantity = sum(quantity),
    summed_total_val = sum(total_value)
  ) 

Look at local cities

Filter summed quantity and totals data for only specific local departments

# create list of reusable local dept.'s
local_agencies <- c(
  "AUSTIN POLICE DEPT",
  "SAN MARCOS POLICE DEPT",
  "TRAVIS COUNTY SHERIFFS OFFICE",
  "UNIV OF TEXAS SYSTEM POLICE HI_ED",
  "WILLIAMSON COUNTY SHERIFF'S OFFICE"
)

# filter quant/total data for only local agencies
tx_quant_totals %>% 
  filter(agency_name %in% local_agencies)

Breakdown local agency items

Finding the sums of each different item each local agency has received since 2010

Austin Police Department items

What did our city buy the last 10 years?

Austin Population: 961,855 (2020 Census)

tx %>% 
  filter(
    agency_name == "AUSTIN POLICE DEPT" # get only Austin entries
  ) %>% 
  group_by(item_name) %>% # group same items together
  summarize(
    summed_quantity = sum(quantity), #sum all quantities
    summed_total_val = sum(total_value) # sum all totals
  ) %>% 
  arrange(summed_total_val %>% desc()) #arrange by most expensive

Last 5 years (since Jan. 01, 2015)

Let’s take a closer look

tx %>% 
  filter(
    agency_name == "AUSTIN POLICE DEPT", # get only Austin entries
    ship_date >= "2015-01-01"
  ) %>% 
  group_by(item_name) %>% # group same items together
  summarize(
    summed_quantity = sum(quantity), #sum all quantities
    summed_total_val = sum(total_value) # sum all totals
  ) %>% 
  arrange(summed_total_val %>% desc()) #arrange by most expensive
tx %>% 
  filter(
    agency_name == "AUSTIN POLICE DEPT", # get only Austin entries
    ship_date >= "2015-01-01"
  ) %>% 
  summarize(
    summed_quantity = sum(quantity),
    summed_total_val = sum(total_value)
  ) 
tx %>% 
  filter(
    agency_name == "AUSTIN POLICE DEPT", # get only Austin entries
  ) %>% 
  summarize(
    summed_quantity = sum(quantity),
    summed_total_val = sum(total_value)
  ) 

San Marcos Police Dept. items

Ok, let’s take a look at San Marcos

San Marcos Population: 67,553 (2020 Census)

tx %>% 
  filter(
    agency_name == "SAN MARCOS POLICE DEPT" # get only San Marcos entries
  ) %>% 
  group_by(item_name) %>% # group same items together
  summarize(
    summed_quantity = sum(quantity), #sum all quantities
    summed_total_val = sum(total_value) # sum all totals
  ) %>% 
  arrange(summed_total_val %>% desc()) #arrange by most expensive

Travis Co. Sheriff’s Office items

Ok, let’s take a look at Travis County

Travis County Population: 1,290,188 (2020 Census)

tx %>% 
  filter(
    agency_name == "TRAVIS COUNTY SHERIFFS OFFICE" # get only Travis Co. Sheriff entries
  ) %>% 
  group_by(item_name) %>% # group same items together
  summarize(
    summed_quantity = sum(quantity), #sum all quantities
    summed_total_val = sum(total_value) # sum all totals
  ) %>% 
  arrange(summed_total_val %>% desc()) #arrange by most expensive

University of Texas Police

Ok, now let’s look at UT

Travis County Population: 1,290,188 (2020 Census)

tx %>% 
  filter(
    agency_name == "UNIV OF TEXAS SYSTEM POLICE HI_ED" # get only Travis Co. Sheriff entries
  ) %>% 
  group_by(item_name) %>% # group same items together
  summarize(
    summed_quantity = sum(quantity), #sum all quantities
    summed_total_val = sum(total_value) # sum all totals
  ) %>% 
  arrange(summed_total_val %>% desc()) #arrange by most expensive

Williamson County Sheriff’s Office items

Lastly, let’s take a look at Williamson

Williamson County Population: 609,017 (2020 Census)

tx %>% 
  filter(
    agency_name == "WILLIAMSON COUNTY SHERIFF'S OFFICE" # get only Williamson Co. Sheriff entries
  ) %>% 
  group_by(item_name) %>% # group same items together
  summarize(
    summed_quantity = sum(quantity), #sum all quantities
    summed_total_val = sum(total_value) # sum all totals
  ) %>% 
  arrange(summed_total_val %>% desc()) #arrange by most expensive

Some notable equipment

  • MINE RESISTANT VEHICLE: Mine-Resistant, Ambush-Protected vehicle developed to withstand impact from roadside bombs in Iraq and Afghanistan. Mostly used in parades, but have been deployed in standoffs with active shooters. (San Marcos: 1, Travis County: 1, )
  • UNMANNED VEHICLE,GROUND: UGVs; Robotics vehicle used for many applications militarily like explosive ordinance disposal (EOD) such as landmines, loading heavy items, and repairing ground conditions under enemy fire; Civilian uses include urban search and rescue, fire fighting, and nuclear response. (San Marcos: 3)
  • 510 PackBot: tactical mobile robot developed by Endeavor Robotics; used for high-threat scenarios such as surveillance, chemical and biological detection, and bomb disposal. (Travis County: 1, Williamson County: 2, San Marcos: 1, Austin: 4)