Skip to content

Instantly share code, notes, and snippets.

@hansthompson
Created July 12, 2017 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansthompson/8297de072cb094c0b29eb5340aaee958 to your computer and use it in GitHub Desktop.
Save hansthompson/8297de072cb094c0b29eb5340aaee958 to your computer and use it in GitHub Desktop.
get housing data and make a couple plots
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")
# n of houses on the market
by_year <- foo %>% filter(Date >= ymd("2013-1-1")) %>% mutate(year = year(Date)) %>% filter(Month %in% c("Jan", "Feb", "Mar", "Apr", "May", "Jun")) %>%
group_by(year) %>% summarize(New_Listings = sum(New.Listing.Count))
ggplot(by_year) + geom_bar(aes(x = year, y = New_Listings), stat = "identity") +
theme_par() + ggtitle("Newly Listed Properies Jan Through Jun - Anchorage") + labs(caption = "source: http://research.realtor.com/data/inventory-trends")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment