Learn R Programming

EIAdata (version 0.1.3)

EIAdata-package: R wrapper for the US Energy Information Administration's (EIA's) API.

Description

This package allows the user to query categories, and import data, through the EIA's API. Resulting time series are objects of class xts. The EIA API offeres access to over a million unique time series. The package also contains a function which returns the latest EIA Natural Gas Storage Report.

Arguments

Details

Package: EIAdata
Type: Package
Version: 0.1.2
Date: 2022-01-10
License: GPL-2

References

http://www.eia.gov/beta/api/

Examples

Run this code
# NOT RUN {
# \dontrun is used here because the functions require a valid EIA API key.

# While API keys are free, they are best kept private.

# Be sure to load your EIA key.  You can request one
# here: http://www.eia.gov/beta/api/register.cfm

key <- "your_key"

# To see the top of the data category hierarchy.

getCatEIA(key=key)

# To see the subcategories and data sets in a particular category (for example 40827).

getCatEIA(key=key, cat=40827)

# To download and return a time series object of class xts
# for example ELEC.PLANT.GEN.13-WAT-ALL.Q

getEIA(ID = "ELEC.PLANT.GEN.13-WAT-ALL.Q", key = key)

# The if the EIA series ID contains a "-", the function will replace
# this with a ".".  So the call above will return a time series of
# class xts named ELEC.PLANT.GEN.13.WAT.ALL.Q
# }

Run the code above in your browser using DataLab