The Chronicle of Higher Education released a list of the financial composite scores for each private university in the United States. I wanted to try and work with the leaflet package to create an interactive map. Here’s what I came up with.
I had to get the dataframes into the right format for the leaflet package to work properly. That required some cleaning and some merging. The most important thing I did was use the geocode function in the ggmap package to acquire the longitude and latitude of every college on the list. Unfortunately it wasn’t 100% accurate, but it got it right most of the time.
I also wanted to create a helpful pop up whenever the user clicked on one of the dots. Here I created a pop up that did two things. First, it the name of the college. Second, it gives the composite score which indicates overall financial health.
I wanted to create a green, yellow, red legend so that people could easily see which schools were in the worse trouble. In order to do that I had to write a simple function to break the scores down into three categories. Then I wanted to use some nice icons.
I really liked the look of a darker map, so I wanted to use that as my base. In addition I wanted the map to be zoomed to the center of the United States to give the user a nice starting point.
The Finished Product
Every college in the database is mapped here. The scores range from -1 to 3. Any school that scores 1.5 or lower is considered to be in financial distress.