Growth in consumer prices
RECENT DATA INDICATE THAT CONSUMER PRICES INFLATION is ticking up, though the overall pace of inflation remains below historical averages. In this post I’m going to create a few plots analyzing trends in the Consumer Price Index (CPI) published by the U.S. Bureau of Labor Statistics (BLS).
These visualizations will be made in R, and I’ll post code for some of the graphs as we go.
The BLS has made getting the data quite convenient by providing well organized flat text files that are easy to read. The code below loads some libraries and grab data from the BLS page:
Load some libraries:
Load some data
The code below goes to the BLS website and downloads the text files. This file contains summary information about the flat files.
Make some charts
First let’s look at the level of consumer prices for major aggregates relative to the year 2000.
We can also animate this chart:
Code for animation:
Comparing year-over-year inflation
The chart above shows the longer-run inflation for major categories since the year 2000, what about more recent inflation trends? Let’s examine year-over-year changes by major category:
Animated version using tweenr
We can also use tweenr to generate a smooth animation for the plot.
See my earlier post about tweenr for an introduction to tweenr, and more examples here and here.
Here’s the code:
Which gives us:
And of course, we can make the lollipop dance: