In my corner of the internet, there's been an explosion over the last several months of a style of graph called a bar chart race. Essentially, a bar chart race shows how a ranked list of something--largest cities, most valuable companies, most-followed Youtube channels--evolves over time. Maybe you've been following this trend with the same curiosity that I have, and that's how you made your way here. Or maybe you're a normal person who doesn't even know what I'm talking about! Who knows, anything is possible. By way of introduction, here is the bar chart race I've created on the largest cities in the United States over time: Motivation for this post For me, it all started with this brand value graphic that went viral back in February. For a few days, it felt like this thing was everywhere. And as this went viral, data visualization practitioners all started to try their hand at creating new versions of this on their own. One of my favorites was this bar chart race of world cities created by John Murdoch, who, as far as I can tell, was the person who coined the term bar chart race. Of course, I knew that I wanted to try to create a version of this graph in R. And for as long as I an remember, I've been obsessed with looking at population statistics for cities. I remember finding an Almanac (!) on my dad's bookshelf as a kid and memorizing the list of the largest cities in the United States. Later, I remember reading that Detroit had at a time been among the largest cities in the country. From 1916 to 1944, Detroit was the fourth largest city in the country. Its population peaked at 1.85 million in 1950. Today its population is estimated to be 673,000. The history of Detroit's population in particular was interesting to me. Having grown up Toledo, Ohio, 60 miles south of Detroit, I'd seen the effects of Detroit's dramatic population decrease first-hand. I wanted to see how this story played out in the data, and what other interesting trends would be unearthed. So when I decided I wanted to create a bar chart race, I knew the subject I was going to study. If you're here to learn how to create a bar chart race in R, you're in the right place! Now, let's get into it! Loading packages and data We start by loading the packages we'll use to create the graph. gganimate provides the toolkit for animation, tidyverse will help with data processing and graphing, and hrbrthemes provides a nice-looking base graphing theme. library(gganimate) library(hrbrthemes) library(tidyverse) Now we load in some preprocessed census population data, based on decadal U.S. Census data from 1790 - 2010. This combines the data all into one large dataset we will be using for this analysis. # Read in Census datasets by year that I downloaded and stored locally all_data