Commercial Energy Rates – R Shiny App

Here is a link to a US commercial energy rates shiny application I posted to in 2014. The app pulls in data from the US Energy Information Administration which posts US residential, commercial, industrial and transportation energy prices at the state level to this webpage on a monthly basis. At the time I created this app my employer was specifically interested in commercial energy rates.

commercial energy rates
Screengrab from EIA website where energy rates are posted every month

The app also pulls in 2013 US census population data from the US Census Bureau. [Note: reading in data from external websites like this is a little risky since it creates an external dependency but at the time I was keen to learn new things about R! For a more robust application, just get the population data one time and store it on your own system where you can control it.]

So what?

My company sold energy management hardware and software solutions to commercial entities in retail, grocery and fast food industries. Like any company we had limited sales and marketing resources. This tool helped efficiently allocate those resources to where returns were more likely, i.e. states with high energy costs and/or states with rising energy costs. Yes, you could just look up the data from tables on the website but this visualization makes it instantly apparent where the most interesting data opportunities are.

energy rates app
Bubble plot to demonstrate costs, change in costs, state population

Key features of the app:

  • By labelling the points and color coding them according to geographic region we can see at a glance that California and a bunch of northeastern states have substantially higher energy costs than the rest of the country.
  • We can also see that West Virginia has seen a 10+% year-on-year increase in costs. Their rates are still low relative to other states but if you are running a business in West Virginia, you are going to feel a 10+% increase in running costs.
  • The size of the points is proportional to population. A useful visual reminder that the opportunities in West Virginia may be slim on the ground (although the scenery is stunning and the locals are friendly!)

The app also features links to the raw data sources and 2 map views – notice again how California and West Virginia stand out for highest rates and highest increase in rates respectively.

energy rate maps
Map views for all you GIS nerds out there!

As usual, here is a link to the code that I have saved in Google Drive and that you are free to download and run in R. Notes on running this shiny application:

  1. Download the zip file and extract the 2 R files to a suitable location on your device. Let’s assume you saved them to “C:/My Documents/energyRatesApp”.
  2. Set your working directory to this address: setwd(“C:/My Documents/”)
  3. Ensure the shiny library is installed: install.packages(“shiny”)
  4. Run the app: shiny::runApp(“energyRatesApp”)
  5. You may get error messages if all the required libraries are not installed. Simply install the necessary libraries and try again.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s