The USgrid R package provides a set of high frequency (hourly) time-series datasets, describing the demand and generation of electricity in the US (lower-48 states, excluding Alaska and Hawaii). That includes the following series:

  • US_elec - the total hourly demand and supply (generation) for electricity in the US since July 2015

  • US_source - the hourly demand for electricity in the US by energy source (natural gas, coal, solar, etc.) since July 2018

  • Cal_elec - The California subregion hourly demand by operator since July 2018

Data structure

All the series are in tsibble format

The US total demand and supply for electricity

The US_elec series describes the total hourly demand and supply (generation) of electricity in the US since July 2015:

library(USgrid)

data("US_elec")

head(US_elec)
#>             date_time series   type
#> 1 2015-07-01 05:00:00 162827 demand
#> 2 2015-07-01 06:00:00 335153 demand
#> 3 2015-07-01 07:00:00 333837 demand
#> 4 2015-07-01 08:00:00 398386 demand
#> 5 2015-07-01 09:00:00 388954 demand
#> 6 2015-07-01 10:00:00 392487 demand

Where the type variable defines the series key (i.e., demand or generation). As you can see in the plot below, the generation of electricity is relatively close to the demand:

library(plotly)

plot_ly(data = US_elec,
        x = ~ date_time,
        y = ~ series,
        color = ~ type,
        line = list(width = 1),
        type = "scatter",
        mode = "lines") %>%
  layout(title = "US Electricity Generation vs. Demand",
         yaxis = list(title = "Mwh"),
         xaxis = list(title = "Source: US Energy Information Administration (Mar 2021)"))

Generation by energy source

The US_source series describes the net generation of electricity by energy source (i.e., natural gas, coal, solar, etc.) since July 2018:

library(tidyr)

data("US_source")

source_wider <- US_source %>% 
  pivot_wider(names_from = source, values_from = series)

 plot_ly(data = source_wider, x = ~date_time, y = ~`natural gas`, 
             name = "Natural Gas", 
             type = "scatter", 
             mode = "none", 
             stackgroup = "one", 
             groupnorm = "percent",
             fillcolor = "lightgreen") %>%
  add_trace(y = ~coal, name = "Coal", fillcolor = "#7f7f7f") %>%
  add_trace(y = ~nuclear, name = "Nuclear", fillcolor = "#F5FF8D") %>%
  add_trace(y = ~hydro, name = "Hydro", fillcolor = "red") %>%
  add_trace(y = ~wind, name = "Wind", fillcolor = "#1f77b4") %>%
  add_trace(y = ~other, name = "Other", fillcolor = "#e377c2") %>%
  add_trace(y = ~solar, name = "Solar", fillcolor = "orange") %>%
  add_trace(y = ~petroleum, name = "Petroleum", fillcolor = "black") %>%
  layout(title = "US Electricity Generation by Energy Source Dist.",
         xaxis = list(title = "Source: US Energy Information Administration (Mar 2021)",
                      showgrid = FALSE),
         yaxis = list(title = "Percentage",
                      showgrid = FALSE,
                      ticksuffix = "%"))

California subregion - demand by operator

The Cal_elec series provides hourly demand by operator since July 2018 for California subregion. That includes the following operators:

  • Pacific Gas and Electric
  • San Diego Gas and Electric
  • Southern California Edison
  • Valley Electric Association
data("Cal_elec")

plot_ly(data = Cal_elec,
        x = ~ date_time,
        y = ~ series,
        color = ~ operator,
        type = "scatter",
        mode = "lines") %>%
  layout(title = "California Hourly Demand by Operator",
         yaxis = list(title = "Mwh"),
         xaxis = list(title = "Source: US Energy Information Administration (Mar 2021)"))