How to Build a Data Dashboard using R (knitr), HTML, and Javascript (e.g.,Highcharts)

R has been the perfect language for the back end of this government data dashboard I am developing. It has excellent packages to pipe in data from every significant source Tools like dplyr and tidyr make cleaning and munging data trivial It is ideal for automating analysis In the R script that powers my dashboard, I have everything from simple averages and frequency tables, to a complex algorithm that converts timeseries figures to Z-Scores and then selects the top 3 variables to display based on standard scores from the last 7 days.

The Top Urban Planning Articles of 2014

For my job, I read a lot of articles on urban policy and planning. I believe that the best policies are usually borrowed from other cities rather than fabricated from nothing. In that spirit, I even borrowed from other top ten lists to create this post. I like to think that my list is more comprehensive than some of the others since I have no incentive to link to my own content.

The Most Magazine Covers of All Time

Time is a weekly news magazine that was first published in New York City in 1923. After my last post, a generous redditor offered to share with me a dataset of every person who has appeared on the cover since its first issue. It turns out he had painstakingly collected this data for a very cool website he created called hugequiz.com, where there are multiple quizzes on this subject. Fortunately, I don’t think it will spoil any of the quizzes to see this chart of the most frequently featured people:

Grammy Counts Favor Musicians From the Aughts

The 57th annual Grammy nominations were recently announced, cementing Beyonce as the most nominated female artist in history. She is now tied with Kanye for a career total of 53 nominations. This news made me curious enough to plot the top award winners of all time. I did not recognize the knight at the top of the list (turns out he is an amazing conductor with a storied history as director of the CSO); but I sort of expected that.

The most-viewed non-music YouTube videos

Randal Olson just posted a terrific explanation of the storage significance of Psy’s massive view count along with a chart of the top YouTube videos, which prompted a popular comment from u/promyy: “I’d love to see a chart of most viewed, non-music videos on YouTube.”

.adslot_1 { max-width: 720px;} (adsbygoogle = window.adsbygoogle || []).push({});
I didn’t have a special coding solution for this; Instead, I just went through a list linked from the Wikipedia article and copy-pasted videos that I felt qualified.

Data Analysis of the 2014 Mass. Gubernatorial Election

Coakley received a lot of votes from residents of Massachusetts’s major cities. This is evident in the maps I posted last week, and in the charts below. What may be surprising is how many votes Baker received in cities, including Boston: Baker received nearly 10,000 more votes in Boston than he did in 2010. If those had gone to Coakley instead, the spread between them would have been cut roughly in half.

How To Automate Map Making in R

In my last post, I displayed a series of maps from the 2014 Massachusetts midterm election. In all, I created 17 maps, all with fewer than 20 lines of code. Here’s how… The basic idea is to use a For Loop with ggmap to iterate through columns of a data frame. In my example, the code for which can be found here, I first read shapefiles from MassGIS into R, and then combine them with election data.

Maps of the 2014 Massachusetts Elections

Most of the maps I have seen so far color each city or town either red or blue based on the majority outcome. That works fine, for the most part, but I prefer to see the range of voting patterns. These heat maps go from light yellow to dark blue. The scale changes on each one in order to show the full spectrum. I managed to automate their creation in R.

The Political and Public Opinion of Same-Sex Marriage, by State

According to polling data, this is a current map of popular support for same-sex marriage: It is important to note that this map shows where people say they support same-sex marriage, but each state also contains a significant proportion of voters who are either indifferent or unsure. Compare that map to this one of political support in congress and the governor’s office: As you would expect, political support is correlated to public opinion, but not perfectly.

Using Machine Learning to Detect Stylometric Differences Between Nick and Amy in Gone Girl

I wanted to see if it was possible to train a model to detect the difference between two fictional authors created by the same novelist based only on the frequency of common stop words, e.g., “the.” It worked: The randomForest model correctly selected Nick 93% of the time and Amy 91%. Background When I first started using R for data analysis, I was mesmerized by all of the packages and what they made possible.