Skip to content

Instantly share code, notes, and snippets.

Avatar

Charles Hans Thompson hansthompson

  • Anchorage, Alaska
View GitHub Profile
@hansthompson
hansthompson / anchorage_housing.R
Created Jul 12, 2017
get housing data and make a couple plots
View anchorage_housing.R
library(ggplot2);library(dplyr);library(lubridate)
foo <- read.csv("https://s3-us-west-2.amazonaws.com/econresearch/Reports/Core/RDC_InventoryCoreMetrics_Metro_Hist.csv", stringsAsFactors = FALSE)
foo <- foo %>% filter(CBSATitle == "Anchorage, AK") %>%
mutate(Date = ymd(Month),
Month = month(Month, lab = TRUE))
# median price
ggplot(foo) + geom_line(aes(x = Date, y = Median.Listing.Price)) + theme_par() + ggtitle("Median Listing Price - Anchorage") + labs(caption = "source: http://research.realtor.com/data/inventory-trends")
@hansthompson
hansthompson / GTFS2PostGIS.R
Created Mar 9, 2016
A script I use to import Mat-Su region gtfs into PostGIS
View GTFS2PostGIS.R
# NOTES BEFORE CONTINUING
# Problem 1. Time datatype for systems that go past midnight needs to have the right definition. So it won't work with trimet because it goes beyone midnight.
# Problem 2. Needs a service to find the correct projection to move from WGS84 to a local plane for accurate measurements in meters. Maybe I'm off here
# Problem 3. Since I set my machine up to need sudo commands for Postgres I don't know the best method as an admin to do database connections without sudo.
#system(paste("sudo -kS -u postgres psql -c 'CREATE DATABASE ", database_name, "'"), input=readline("Enter your password: "))
#Variables to set
database_name <- "nameOfDatabase"
zipfile <- "zipfile/path"
@hansthompson
hansthompson / AK_example.R
Created Oct 12, 2015
Receating the R package tigris example for Alaska. Single digit state codes and double digit county codes have no leading zeros and won't merge.
View AK_example.R
library(tigris)
dfw <- tracts(state = '02', county = '020', detailed = FALSE)
library(acs)
library(leaflet)
api.key.install("API_KEY" )
income_data <- acs.fetch(endyear = 2012,