Sunday, August 24, 2014

Cost of Living


Recently, someone posted a map of the cost of living for states in the US.  The issue was that the state level is way too high to look at that.  I decided to do it at the county level.

First I had to find a data source for the cost of living at the county level.  I found this site, which seems to have good county level data.  I wrote a script to scrape that data, and then had a csv with the cost of living and fips code for every county.

For plotting I followed this R tutorial.  It was easy enough to follow/adapt, but I noticed the result looked odd.  It was much more random than I would have expected, and some spot checking confirmed the plot was wrong.  It took me quite a while to figure out there were a few counties that are out of order in the maps package.  This still doesn't make sense as I used a match command so they should all be matched up.  Either way, I finally got an R script that plotted the data correctly.

The code and data are up on github.


No comments:

Post a Comment