Learn R Programming

RTL (version 1.3.2)

eia2tidy_all: EIA API multiple calls with tidy output

Description

Extracts data from the Energy Information Administration (EIA) API to tibble format with optional custom series name. Makes a clean wrapper for use with purrr for multiple series extraction. Query Browser at https://www.eia.gov/opendata/qb.php.

Usage

eia2tidy_all(
  tickers = tibble::tribble(~ticker, ~name, "PET.W_EPC0_SAX_YCUOK_MBBL.W",
    "CrudeCushing", "NG.NW2_EPG0_SWO_R48_BCF.W", "NGLower48"),
  key,
  long = TRUE
)

Value

A tibble object with class date for weekly, monthly, quarterly or annual data and class POSIXct for hourly.

Arguments

tickers

tribble of EIA series and names you want to assign.

key

Your private EIA API token as character "yourapikey".

long

TRUE (default) to return a long data frame or FASLE for wide

Author

Philippe Cote

Examples

Run this code
if (FALSE) {
eia2tidy_all(tickers = tibble::tribble(~ticker, ~name,
                         "PET.W_EPC0_SAX_YCUOK_MBBL.W", "CrudeCushing",
                         "NG.NW2_EPG0_SWO_R48_BCF.W", "NGLower48"),
            key = "your API key", long = TRUE)
}

Run the code above in your browser using DataLab