decctools

decctools is an R package that provides easy access to energy statistics from the United Kingdom Department of Energy and Climate Change. It currently provides access to two major data sources:

You must have Curl installed to use this package.

Sub-national statistics

Sub-national energy statistics are available at three different geographies: Local Authority Districts (LADs), Middle Super Output Areas (MSOAs), and Lower Super Output Areas (LSOAs). For each geography, the following functions are available where * corresponds to the correct level (LAD, MSOA, or LSOA).

Here's an example:

   ## Gets energy data for electricity and gas use in the domestic sector in the most recent year
   df <- get_LAD_data(sector="domestic", fuel=c("electricity", "gas"))
   

You may encounter OutOfMemoryError (Java) when loading LSOA data. In this case, close R, open a new session, and type options(java.parameters = "-Xmx1000m") before loading decctools. This increases the maximum amount of memory allowed for Java so you may need to change the 1000 value to match the available memory on your machine.

The package provides a lookup table to match LAD, MSOA, and LSOA id codes; this is accessible via get_geo_lookup. Owing to the frequent changes in UK geography in recent years, it is advisable to merge LAD data on the name field.

You can also check if a given LAD is urban or rural by using is_urban(LAD, urban) where urban is a set of codes defining which ONS urban classifications you would like to consider as urban.

Grid carbon intensity

Elexon's BM Reports provides data on the UK's electricity market including the amount of electricity generated by different fuel types in each half-hourly period of the day. Historic data (back to 2009-01-01) has been archived by the charity Renewable Energy Foundation and decctools uses their summaries to provide the data used here.

There are two methods of interest:

An example:

get_grid_carbon('2013-05-01', '2013-05-31')