eia2tidy: 'eia2tidy'

Description Usage Arguments Value Author(s) Examples

View source: R/eia2tidy.R

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

1
eia2tidy(ticker, key, name = " ")

Arguments

ticker

EIA series name.

key

Your private EIA API token as character "<yourapikey>".

name

Name you want to give the series. Defaults to ticker if set to " "

Value

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

Author(s)

Philippe Cote

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
Single Series
RTL::eia2tidy(ticker = "PET.MCRFPTX2.M", key = "<yourapikey>", name = "TexasProd")
Multiple Series
eia_df <-tibble::tribble(~ticker, ~name,
"PET.W_EPC0_SAX_YCUOK_MBBL.W", "CrudeCushing",
"NG.NW2_EPG0_SWO_R48_BCF.W","NGLower48") %>%
 dplyr::mutate(key = "EIAkey") %>%
 dplyr::mutate(df = purrr::pmap(list(ticker,key,name),.f=RTL::eia2tidy)) %>%
 dplyr::select(df) %>% tidyr::unnest(df)
 
## End(Not run)

RTL documentation built on June 12, 2021, 5:06 p.m.