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)
install.packages("remotes") remotes::install_github("laderast/burro") # Install from the source repository, # if you are not running in a fork of the craggy2019 project. # remotes::install_github("pdxrlang/craggy_2019")
Once installed, run from here on...
knitr::opts_chunk$set(echo = TRUE) library(burro) library(tidyr) library(dplyr) library(janitor) library(craggy2019)
evictions
datasetevictions <- readr::read_csv(system.file("extdata", "evictions.csv", package = "craggy2019")) %>% 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)
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(system.file("extdata", "forecloseWATract.csv", package = "craggy2019")) %>% 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)
This one doesn't work - I will push fixes to burro
.
king_zillow <- readr::read_csv(system.file("extdata", "king_zillow.csv", package = "craggy2019")) burro::explore_data(king_zillow,outcome_var = NULL)
one_night <- readr::read_csv(system.file("extdata", "oneNightCount.csv", package = "craggy2019")) %>% janitor::clean_names() %>% tidyr::gather("neighborhood", "count", -year, -location) burro::explore_data(one_night)
# Sample code for grabbing spatial data library(tigris) 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.