clean_facility_name: A facility name cleaning function. Uses GitHub facility name...

View source: R/clean_facility_name.R

clean_facility_nameR Documentation

A facility name cleaning function. Uses GitHub facility name cross-walk to find all possible name variations

Description

A facility name cleaning function. Uses GitHub facility name cross-walk to find all possible name variations. Cleans federal and non-federal facilities in separate processes, in order to use "State" to merge or not. If no match is found in the crosswalk, both Facility.ID and Jurisdiction will equal NA in the resulting output.

Usage

clean_facility_name(dat, alt_name_xwalk = FALSE, debug = FALSE)

Arguments

dat

Scraped/historical data with columns Name and State, at the very least

alt_name_xwalk

Optional parameter provides an alternative facility name crosswalk

debug

Boolean whether to include additional columns geneated during the merging process

Details

This function assumes that if a faceility is federal, then vars "Facility" OR "State" OR "Jurisdiction" will contain the word federal (case-insensitive).

For non-federal entities, the data returned gets "Jurisdiction" from fac_spellings

For federal + immigration entities, the data returned gets "Jurisdiction" and "State" from fac_spellings

When there is not enough info to get a match, both "Jurisdiction" and "Facility.ID" will be returned as NA

Value

data set with cleaned columns, "Name", "Facility.ID", and "Jurisdiction" from fac_spellings

Examples

clean_facility_name(
    tibble(Name = "BULLOCK CORRECTIONAL FACILITY", State = "Alabama", Jurisdiction = "state"))

clean_facility_name(
    tibble(Name = "LEE USP", State = "Federal", Facility = "prison"))


uclalawcovid19behindbars/behindbarstools documentation built on April 22, 2022, 4:08 a.m.