Clean up some columns

sum(lt$yr_alloc == 8888)
## [1] 43
lt <- lt %>% 
  mutate(yr_alloc = if_else(yr_alloc == 8888, NA, yr_alloc)) #%>% 
  # mutate(across(c(scattered, basis, bond, mff_ra, fmha_514, fmha_515, home, tcap, cdbg, htf, fha, hopevi, trgt_eld, trgt_dis, trgt_hmi, trgt_other, trgt_spc, qct, nonprog)))



range(lt$yr_alloc, na.rm =T)
## [1] 1987 2024
n_years <-  max(lt$yr_alloc, na.rm=T)- min(lt$yr_alloc, na.rm =T) 
hist(lt$yr_alloc, breaks = n_years)

QCT means qualified cencus tract. This shows that properties in a QCT are significantly larger than those in a non-qualified tract.

boxplot(li_units~type, data=lt, outline=FALSE)

boxplot(li_units~type, data=lt, outline=FALSE)

t(table(lt$qct, lt$yr_alloc))
##       
##         1  2
##   1987  0 18
##   1988  0 59
##   1989  0 78
##   1990  0 35
##   1991  0 60
##   1992  0 24
##   1993  0 15
##   1994  0 23
##   1995  0 23
##   1996  0 12
##   1997  0 13
##   1998  1  4
##   1999  2  1
##   2000  5  2
##   2001  7  2
##   2002  6  3
##   2003 10  1
##   2004  9  1
##   2005  7  0
##   2006 10  2
##   2007  3  4
##   2008  1  0
##   2010  0  1
##   2011  0  2
##   2012  4  2
##   2013  0  0
##   2014  4  3
##   2015  5  0
##   2016  3  3
##   2017  5  3
##   2018 10  1
##   2019 10  4
##   2020  4  3
##   2021 13  1
##   2022  5  0
##   2023  3  0
##   2024  4  0

Basically, we are looking at projects that were allocated in 2004 or earlier.

t(table(lt$nonprog, lt$yr_alloc))
##       
##         1
##   1987 18
##   1988 59
##   1989 78
##   1990 35
##   1991 59
##   1992 19
##   1993  7
##   1994 13
##   1995  8
##   1996  4
##   1997  2
##   1998  0
##   1999  0
##   2000  1
##   2001  1
##   2002  2
##   2003  2
##   2004  3
##   2005  0
##   2006  0
##   2007  0
##   2008  0
##   2010  0
##   2011  0
##   2012  0
##   2013  0
##   2014  0
##   2015  0
##   2016  0
##   2017  0
##   2018  0
##   2019  0
##   2020  0
##   2021  0
##   2022  0
##   2023  0
##   2024  0

Make some maps

lt_sf <- lt %>% 
  filter(!if_all(c("latitude", "longitude"), is.na)) %>% 
  st_as_sf(coords = c("longitude", "latitude")) %>% 
  st_set_crs(4326)
tmap_mode("view")
## ℹ tmap mode set to "view".
lt_sf  %>% 
  tm_shape() +
  tm_dots("yr_alloc", size = "li_units")
## Registered S3 method overwritten by 'jsonify':
##   method     from    
##   print.json jsonlite