Is gas cheaper than it used to be?

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Biostatistician and R user Matt Cooper noticed recently that the price he pays for petrol (gasoline) at the pump in Perth, Australia was about the same as he was paying four years ago. Nonetheless, inflation has marched on over the years, so does that mean petrol is effectively cheaper now than it used to be? And how does the price of gas today compare to historic prices, when you adjust for the effects of inflation?

To answer this question, Matt imported retail fuel price data from the Western Australia Department of Commerce and Australian inflation data (the Consumer Price Index). He then converted the historical fuel prices into constant 2001 dollars using R to create the chart below: 

Looking at the red line on the chart (the retail, or signboard prices) you can see a steady upward trend with a big downward correction in late 2008. But looking at the green line (in constant 2001 dollars), you see a much shallower trend. And petrol prices four years ago (just before the correction) were actually more expensive than they are today: around AUD$1.17/litre (in 2001 dollars) compared to AUD$0.98 today.

I was going to recreate Matt's charts for gas prices here in California, but I couldn't find a public source of retail gas data for the US. Nonetheless, reading from this chart of retail gas prices in California:


the price four years ago was around $3.90, which in 2012 dollars is around $4.16. That's comparable to the prices at the pump today, so Matt's experience in Australia is broadly reflected here in this part of the US as well. If you can find public retail gas price and inflation data, Matt's R code should help you to create a similar chart for your region, and can be found in his blog post linked below. (By the way, Matt used the knitr package to create his blog post combining text, code and charts; the MarkDown source Matt provided is a great example of using knitr to create attractive documents from R code.)

Matt's Stats n stuff: Petrol prices adjusted for inflation

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)