Learn R Programming

RTL (version 0.1.3)

eia2tidy: eia2tidy

Description

Converts output of getEAI() in a tidy tibble with names("date","value"). Makes a clean wrapper for use with purrr.

Usage

eia2tidy(ticker, key, name = " ")

Arguments

ticker

EIA series name.

key

EIA API token.

name

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

Value

A tibble object

Examples

Run this code
# NOT RUN {
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)
 
# }

Run the code above in your browser using DataLab