-
Notifications
You must be signed in to change notification settings - Fork 6
/
evictions.Rmd
81 lines (55 loc) · 2.35 KB
/
evictions.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
title: "Looking at Evictions"
author: "Ted Laderas"
date: "8/19/2019"
output: html_document
---
This RMarkdown document gives you a head start by processing the data, and lets you visualize the data using `burro`.
Run this code block to install `burro` (Data exploration app)
```{r eval=FALSE}
install.packages("remotes")
remotes::install_github("laderast/burro")
```
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(burro)
library(here)
```
## Looking at the `evictions` dataset
```{r}
library(dplyr)
evictions <- readr::read_csv(here::here("data/evictions.csv")) %>%
janitor::clean_names() %>%
mutate(low_flag = factor(low_flag), imputed=factor(imputed), subbed=factor(subbed)) %>%
mutate(parent_location = stringr::str_replace(parent_location, pattern = ", Washington", replacement = ""))
burro::explore_data(evictions)
```
```{r}
should_be_numeric <- c("estimated_number_foreclosures", "estimated_number_mortgages", "estimated_foreclosure_rate" , "total_90_day_vacant_residential_addresses","total_residential_addresses","estimated_90_day_vacancy_rate", "total_hicost_2004_to_2006_hmda_loans",
"total_2004_to_2006_hmda_loans",
"estimated_hicost_loan_rate",
"bls_unemployment_rate", "ofheo_price_change")
forclose_wa <- readr::read_csv(here::here("data/forecloseWATract.csv")) %>%
janitor::clean_names() %>% mutate_at(should_be_numeric, ~na_if(., "#NULL!")) %>% mutate_at(should_be_numeric, ~stringr::str_replace(., "%", "")) %>% mutate_at(should_be_numeric, as.numeric) %>% select(-county, -state, -sta)
burro::explore_data(forclose_wa)
```
## Explore King County Zillow Values
This one doesn't work - I will push fixes to `burro`.
```{r eval=FALSE}
king_zillow <- readr::read_csv(here::here("data/king_zillow.csv"))
burro::explore_data(king_zillow,outcome_var = NULL)
```
## One Night Counts
```{r}
one_night <- readr::read_csv(here::here("data/oneNightCount.csv")) %>% janitor::clean_names() %>% tidyr::gather("neighborhood", "count", -year, -location)
burro::explore_data(one_night)
```
```{r eval = FALSE}
# Sample code for grabbing spatial data
library(tigris)
library(here)
options(tigris_use_cache = TRUE)
# Grab shape files for King county at the census tract level
king_spatial <- tracts(state = "WA", county = "King")
dat <- geo_join(spatial_data = king_spatial, evictions, by = "GEOID")
```