Skip to content

Instantly share code, notes, and snippets.


Charles Hans Thompson hansthompson

  • Anchorage, Alaska
View GitHub Profile
hansthompson / anchorage_housing.R
Created Jul 12, 2017
get housing data and make a couple plots
View anchorage_housing.R
foo <- read.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:")
hansthompson / GTFS2PostGIS.R
Created Mar 9, 2016
A script I use to import Mat-Su region gtfs into PostGIS
# 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 / 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
dfw <- tracts(state = '02', county = '020', detailed = FALSE)
api.key.install("API_KEY" )
income_data <- acs.fetch(endyear = 2012,