Introduction to USgas Package
Happy to announce that the USgas package is now on CRAN. The package provides an overview of natural gas demand in the US in a time-series format (state and aggregate levels), with more than 100 series.
This package is a mirror of the USgrid package that focuses on electricity demand (and supply) in the US. Additional information available:
- Source code - https://github.com/RamiKrispin/USgas
- Package site - https://ramikrispin.github.io/USgas/
- Data source - US Energy Information Administration, https://www.eia.gov/
Datasets
Currently, there are three datasets in the package:
us_monthly
- The monthly demand for natural gas in the US between 2001 and 2020us_total
- The US annual natural gas consumption by state-level between 1997 and 2019, and aggregate level between 1949 and 2019us_residential
- The US monthly natural gas residential consumption by state and aggregate level between 1989 and 2020
While the first dataset describes only the US consumption, the second and third describe total and residential consumption by state, respectively.
Visualize the demand for natural gas
The us_monthly
dataset is a monthly series, representing the total demand (or consumption) of natural gas in the US since 2001:
library(USgas)
data("us_monthly")
head(us_monthly)
## date y
## 1 2001-01-01 2676998
## 2 2001-02-01 2309464
## 3 2001-03-01 2246633
## 4 2001-04-01 1807170
## 5 2001-05-01 1522382
## 6 2001-06-01 1444378
Let’s use plotly to visualize the series:
library(plotly)
plot_ly(data = us_monthly,
x = ~ date,
y = ~ y,
type = "scatter",
mode = "line") %>%
layout(title = "US Monthly Natural Gas Consumption",
yaxis = list(title = "Million Cubic Feet"),
xaxis = list(title = "Source: US Energy Information Administration"))
Likewise, the us_total
dataset provides the state (and aggregate) level total consumption of natural gas. Unfurtantully, on the state level, the data is available only in annual format (as opposed to monthly):
data("us_total")
head(us_total)
## year state y
## 1 1997 Alabama 324158
## 2 1998 Alabama 329134
## 3 1999 Alabama 337270
## 4 2000 Alabama 353614
## 5 2001 Alabama 332693
## 6 2002 Alabama 379343
The following plot describes the annual demand in New England states:
us_total %>%
filter(state %in% c("Connecticut", "Maine", "Massachusetts",
"New Hampshire", "Rhode Island", "Vermont")) %>%
plot_ly(x = ~ year,
y = ~ y,
color = ~ state,
type = "scatter",
mode = "line") %>%
layout(title = "New England States Annual Demand for Natural Gas Residential Consumption",
yaxis = list(title = "Million Cubic Feet"),
xaxis = list(title = "Source: US Energy Information Administration"))
Last but not least is the us_residential
dataset, which describes the monthly demand for natural gas by residential consumers:
data("us_residential")
head(us_residential)
## date state y
## 1 1989-01-01 Alabama 7406
## 2 1989-02-01 Alabama 7044
## 3 1989-03-01 Alabama 7392
## 4 1989-04-01 Alabama 4722
## 5 1989-05-01 Alabama 2856
## 6 1989-06-01 Alabama 1709
Similarly, we can plot the residential demand for natural gas in the West Cost states:
library(dplyr)
us_residential %>%
filter(state %in% c("Alaska", "California",
"Oregon", "Washington")) %>%
plot_ly(x = ~ date,
y = ~ y,
color = ~ state,
type = "scatter",
mode = "line") %>%
layout(title = "West Cost Natural Gas Residential Consumption",
yaxis = list(title = "Million Cubic Feet"),
xaxis = list(title = "Source: US Energy Information Administration"))
Road map
The goal for the next release (potentially on Q2) is to add additional series related to the demand for natural gas in the US, such as prices, supply, and production, etc.