R: A function to download data from the Energy Information...
getEIA
R Documentation
A function to download data from the Energy Information Administration's (EIA's) API.
Description
A function to download data from the EIA's API. Resulting time series are of class xts.
Usage
getEIA(ID, key)
Arguments
ID
The EIA API Series ID for the data.
key
Your EIA API key.
Value
xts object (time series)
Author(s)
Matthew Brigida
Examples
## The function is currently defined as
function (ID, key)
{
switch(.last_char(ID), A = .getAnnEIA(ID, key = key), Q = .getQEIA(ID,
key = key), M = .getMonEIA(ID, key = key), W = .getWDEIA(ID,
key = key), D = .getWDEIA(ID, key = key),
print("ERROR: The last
character of your ID is not one of the possible sampling
frequencies (A, Q, M, W, or D)"))
}
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(EIAdata)
Loading required package: XML
Loading required package: plyr
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/EIAdata/getEIA.Rd_%03d_medium.png", width=480, height=480)
> ### Name: getEIA
> ### Title: A function to download data from the Energy Information
> ### Administration's (EIA's) API.
> ### Aliases: getEIA
>
> ### ** Examples
>
> ## The function is currently defined as
> function (ID, key)
+ {
+ switch(.last_char(ID), A = .getAnnEIA(ID, key = key), Q = .getQEIA(ID,
+ key = key), M = .getMonEIA(ID, key = key), W = .getWDEIA(ID,
+ key = key), D = .getWDEIA(ID, key = key),
+ print("ERROR: The last
+ character of your ID is not one of the possible sampling
+ frequencies (A, Q, M, W, or D)"))
+ }
function (ID, key)
{
switch(.last_char(ID), A = .getAnnEIA(ID, key = key), Q = .getQEIA(ID,
key = key), M = .getMonEIA(ID, key = key), W = .getWDEIA(ID,
key = key), D = .getWDEIA(ID, key = key), print("ERROR: The last\n character of your ID is not one of the possible sampling\n frequencies (A, Q, M, W, or D)"))
}
>
>
>
>
>
> dev.off()
null device
1
>