Unit info cleaning

Author

Media Innovation Group

This notebook helps us join together our unit-focused data and our weather station-focused data. The data was compiled by Media Innovation Group data fellows. The information came from the Texas Department of Criminal Justice website, a TDCJ unit prototype list and the National Weather Service website.

Goals of this notebook

Clean up our column names so we can easily combine with our other data.

Loading libraries

Expand this to see code
library(tidyverse)
library(janitor)

Download unit info

Option eval: fasle set to avoid re-download. Change to true for updates.

Expand this to see code
# download.file(
#   "https://docs.google.com/spreadsheets/d/e/2PACX-1vRebFs9O2i0HoygXTtIvuzdVTmyrjX3MeUorU9d4fpYkGX7Bb026OradFQ1MMk2ltcGnyILih6ow4F4/pub?gid=1653039441&single=true&output=csv",
#   "data-original/unit-nws-info.csv")

Importing unit info

Let’s bring in our unit info sheet. This was compiled by us to be used in this project.

Expand this to see code
nws_unit_raw <- read_csv("data-original/unit-nws-info.csv") |> clean_names()
Rows: 101 Columns: 12
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (11): Unit Name, Region, Data Fellow, NWS, NWS ID, Unit Code, Type, Stre...
dbl  (1): Driving miles

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Expand this to see code
nws_unit_raw |> head()

Select columns

I’m gonna change column names and only keep the columns we need.

Expand this to see code
unit_info_clean <- nws_unit_raw |> 
  select(unit_name, region, unit_code, type, nws, nws_id, county)

unit_info_clean

Export data

Our cleaning was pretty easy! Let’s export the data and put it into our processed folder now.

Expand this to see code
unit_info_clean |> write_rds("data-processed/01-unit-info-cleaned.rds")