All the code for the app can be found here.
On the census bureau website, all the data is provided by race. For each of the income groups, I took the specific race data and combined it into a spreadsheet. Hence there are seven spreadsheets, one for each income group. The income group “Average” is actually not part of the original data, I averaged the data from the 5 existing quintiles to create the data for that spreadsheet. You’ll also notice that the census data includes two white categories: “White” and “White, Not Hispanic”. For the purposes of this visualization, I tried to separate all the data by race so the white category used is “White, Not Hispanic”.
This application was developed completely in R. I’m using the Shiny package to create the visualization. Shiny uses a ui and a server file to create a reactive application. What is a reactive application? It’s an application that changes on the fly based on the current inputs. There’s a lot of great documentation on how to develop Shiny applications, check out their main website for more details. If you have a little money to spare, there is a pretty good R tutorial available on Udemy as well. The only thing that really caused me to stumble was the reactive functions in R. Reactive functions create reactive function variables. For example, the first input in my app is “race”, which can be any combination of 0 to 5 options. This vector is actually a function variable as opposed to a standard variable. This means that you have to call it in its function form, so “race()” as opposed to “race”. This tripped me up initially but once you get passed that, Shiny is a fun and not too difficult way to create some pretty cool visualizations.
This was another unexpected hurdle I hit. Shiny server does offer the ability to host Shiny apps but unless you are a student or teacher, it’s pretty expensive. Since I’m using Weebly for my blog which basically steps in for all the complex hosting duties, I had to host this app elsewhere. The Udemy class I purchased above promised a lesson on how to host on Amazon EC2 from Mac OSX but the documentation was outdated so I ended up having to figure it out by myself. Long story short, with quite a bit of effort, I successfully got it hosted on Amazon EC2. I noted the steps so when I have time, I’ll include an A to Z hosting guide for OSX on the blog.