Skip to content

Instantly share code, notes, and snippets.

View plnnr's full-sized avatar

Nick Kobel plnnr

View GitHub Profile
@plnnr
plnnr / chas_t1+t11+T14+T15_summary_function.R
Last active August 2, 2018 18:24
Code containing functions that cleanup CHAS data and reports summary characteristics for Table 1 (income by race) and Table 11 (detailed income distribution) and for Tables 14 and 15 (vacant/available units and units being rented by income range). Demonstrates how to use code with examples for Portland MSA and sub-geographies. CHAS (Comprehensiv…
## Table of contents for CHAS data tables
# T1: Income x race (x housing problems x tenure)
# T2: Income x race (x severe housing problems x tenure)
# T3: Income x housing problem severity, ordered (x tenure)
# T4: Household type x household size x housing problems (x tenure)
# T5: Income x elderly occupant x housing problems (x tenure)
# T6: DISCONTINUED (Income x disability x housing problems)
# T7: Income x cost burden x household type (x tenure)
# T8: Income x cost burden x facilities (x tenure)
# T9: Cost burden x race (x tenure)
@plnnr
plnnr / get_demographic_profile.R
Last active July 31, 2018 23:43
R code to get demographic profile for 2010 and 2016 by feeding in a list of census tract FIPS codes. It also calculates median household income by aggregating tract income data and finding the pareto median.
library(tidyverse)
library(tidycensus)
library(dplyr)
# Uncomment and run this code if it is your first time using tidycensus:
# census_api_key("<your_key_here>", install = T)
# If you do not have a Census API key, you can get one at the link below:
# https://api.census.gov/data/key_signup.html
variable_list = c('B08301_001', 'B08301_003', 'B08301_004', 'B08301_010', 'B08301_016',