Narcan-Evading Drug Found in 28% of Opioids, Demands More Proactive Approach to Harm Reduction

news
code
analysis
howto
Author

Elina Gordon-Halpern

Published

February 12, 2023

Code
library(tidyverse)
library(mapview)
library(sf)
library(RColorBrewer)
library(spData)

#Public Housing Authority Data
path <- "Public_Housing_Authorities.csv"
df <- read_csv(path)

#Cleaning Data
public_housing_data <- df %>% 
   filter((MSGUSPS == "100% Overall probable correctness"),
          (STD_ADDR != "NA"),
          (STD_ST != "NA"),
          (TOTAL_UNITS != 0),
          (HA_PHN_NUM != "NA"),
          (HA_EMAIL_ADDR_TEXT != "NA"))
 public_housing_data <- public_housing_data %>% 
   select(FORMAL_PARTICIPANT_NAME,STD_ADDR,STD_CITY,CNTY_NM2KX,STD_ST,HA_PHN_NUM,HA_EMAIL_ADDR_TEXT,HA_COMBINED_SIZE_CATEGORY,HA_PROGRAM_TYPE,TOTAL_OCCUPIED,PHA_TOTAL_UNITS,NUMBER_REPORTED,REGULAR_VACANT,LAT,LON)

#Renaming Variables
names(public_housing_data)[1] <- 'Name'
names(public_housing_data)[2] <- 'Address'
names(public_housing_data)[3] <- 'City'
names(public_housing_data)[4] <- 'County'
names(public_housing_data)[5] <- 'State'
names(public_housing_data)[6] <- 'Phone'
names(public_housing_data)[7] <- 'Email'
names(public_housing_data)[8] <- 'Size_Category'
names(public_housing_data)[9] <- 'Program_Type'
names(public_housing_data)[10] <- 'Occupancy'
names(public_housing_data)[11] <- 'Total_Units'
names(public_housing_data)[12] <- 'Units_Reported'
names(public_housing_data)[13] <- 'Regular_Vacanies'
names(public_housing_data)[14] <- 'Latitude'
names(public_housing_data)[15] <- 'Longitude'


#Converting to Simple Feature
public_housing_data_sf <- st_as_sf(public_housing_data, coords = c("Longitude", "Latitude"),  crs = 4326)

#Regional Data from spData
US_States <- us_states %>%
  select(NAME, REGION, AREA, total_pop_15, geometry)

names(US_States)[1] <- 'Name'
names(US_States)[2] <- 'Region'
names(US_States)[3] <- 'Area'
names(US_States)[4] <- 'Total_Population_2015'

path2 <- "SAIPE_05-04-2023.csv"
df2 <- read.csv(path2)

#Cleaning Data
poverty_data <- df2 %>%
  select(Name, Percent.in.Poverty) 

#Renaming Variables
names(poverty_data)[1] <- 'Name'

#Joining with US_States
poverty_data_sf <- full_join(US_States, poverty_data)

#Low Income Housing Tax Credit (LIHTC) State Program Data
states <- c("Alabama", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming")
lihtc_status <- c("No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "State LIHTC Program Proposed", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "No Current or Proposed State LIHTC Program", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "State LIHTC Program Proposed", "No Current or Proposed State LIHTC Program", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "State LIHTC Program Proposed", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "No Current or Proposed State LIHTC Program", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program", "No Current or Proposed State LIHTC Program", "State LIHTC Program Enacted", "No Current or Proposed State LIHTC Program")
lihtc_status_bystate <- data.frame(states,lihtc_status)
names(lihtc_status_bystate)[1] <- 'Name'
names(lihtc_status_bystate)[2] <- 'Status'

State_LIHTC_Programs <- full_join(US_States,lihtc_status_bystate) %>%
  filter(Name != "District of Columbia")

#Map the Data: Location of Public Housing Authorities, Status of State LIHTC Program, Percent of State Population in Poverty
mapview(public_housing_data_sf, layer.name = "US Public Housing Authorities") +
  mapview(poverty_data_sf, zcol = "Percent.in.Poverty", layer.name = "Percent of State Population in Poverty", col.regions=brewer.pal(7, "RdYlBu")) +
  mapview(State_LIHTC_Programs, zcol = "Status", layer.name = "Status of Statewide Low Income Housing Tax Credit Program", alpha.regions = 0.5)