All Projects → ropensci → eia

ropensci / eia

Licence: Unknown, MIT licenses found Licenses found Unknown LICENSE MIT LICENSE.md
An R package wrapping the US Energy Information Administration open data API.

Programming Languages

r
7636 projects
CSS
56736 projects

Projects that are alternatives of or similar to eia

Simmer
Discrete-Event Simulation for R
Stars: ✭ 170 (+347.37%)
Mutual labels:  cran, r-package
rcppcnpy
Rcpp bindings for NumPy files
Stars: ✭ 24 (-36.84%)
Mutual labels:  cran, r-package
Arsenal
An Arsenal of 'R' Functions for Large-Scale Statistical Summaries
Stars: ✭ 171 (+350%)
Mutual labels:  cran, r-package
Osrm
Shortest Paths and Travel Time from OpenStreetMap with R
Stars: ✭ 160 (+321.05%)
Mutual labels:  cran, r-package
rdomains
Classifying the content of domains
Stars: ✭ 47 (+23.68%)
Mutual labels:  cran, r-package
Webservices
CRAN WebTechnologies Task View
Stars: ✭ 160 (+321.05%)
Mutual labels:  cran, r-package
oem
Penalized least squares estimation using the Orthogonalizing EM (OEM) algorithm
Stars: ✭ 22 (-42.11%)
Mutual labels:  cran, r-package
Minicran
R package to create internally consistent, mini version of CRAN
Stars: ✭ 123 (+223.68%)
Mutual labels:  cran, r-package
DoReMIFaSol
Téléchargement des données sur le site de l'Insee
Stars: ✭ 25 (-34.21%)
Mutual labels:  open-data, r-package
Littler
A scripting and command-line front-end for GNU R
Stars: ✭ 238 (+526.32%)
Mutual labels:  cran, r-package
Pinp
Pinp Is Not PNAS -- Two-Column PDF Template
Stars: ✭ 134 (+252.63%)
Mutual labels:  cran, r-package
healthyR
Hospital Data Analysis Workflow Tools
Stars: ✭ 21 (-44.74%)
Mutual labels:  cran, r-package
Rblpapi
R package interfacing the Bloomberg API from https://www.bloomberglabs.com/api/
Stars: ✭ 133 (+250%)
Mutual labels:  cran, r-package
RcppEigen
Rcpp integration for the Eigen templated linear algebra library
Stars: ✭ 89 (+134.21%)
Mutual labels:  cran, r-package
Drat
Drat R Archive Template
Stars: ✭ 127 (+234.21%)
Mutual labels:  cran, r-package
Pacman
A package management tools for R
Stars: ✭ 220 (+478.95%)
Mutual labels:  cran, r-package
Rinside
Seamless embedding of R in C++ programs
Stars: ✭ 112 (+194.74%)
Mutual labels:  cran, r-package
Mlr
Machine Learning in R
Stars: ✭ 1,542 (+3957.89%)
Mutual labels:  cran, r-package
Tint
Tint is not Tufte
Stars: ✭ 226 (+494.74%)
Mutual labels:  cran, r-package
rcppsimdjson
Rcpp Bindings for the 'simdjson' Header Library
Stars: ✭ 103 (+171.05%)
Mutual labels:  cran, r-package

eia

Author: Matthew Leonawicz ORCID logo
License: MIT

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Travis build status AppVeyor Build Status Codecov test coverage

CRAN status CRAN RStudio mirror downloads Github Stars

The eia package provides API access to data from the US Energy Information Administration (EIA).

Pulling data from the US Energy Information Administration (EIA) API requires a registered API key. A key can be obtained at no cost here. A valid email and agreement to the API Terms of Service is required to obtain a key.

eia includes functions for searching EIA API data categories and importing time series and geoset time series datasets. Datasets returned by these functions are provided in a tidy format or alternatively in more raw form. It also offers helper functions for working with EIA API date strings and time formats and for inspecting different summaries of series metadata. The package also provides control over API key storage and caching of API request results.

Installation

Install the CRAN release of eia with

install.packages("eia")

To install the development version from GitHub use

# install.packages("remotes")
remotes::install_github("ropensci/eia")

Example

To begin, store your API key. You can place it somewhere like your .Renviron file and never have to do anything with the key when you use the package. You can set it with eia_set_key in your R session. You can always pass it explicitly to the key argument of a function.

library(eia)

# not run
eia_set_key("yourkey") # set API key if not already set globally

Load a time series of net electricity generation.

id <- "ELEC.GEN.ALL-AK-99.A"
(d <- eia_series(id, n = 10))
#> # A tibble: 1 x 13
#>   series_id      name                       units        f     description                         copyright source                iso3166 geography start end   updated       data     
#>   <chr>          <chr>                      <chr>        <chr> <chr>                               <chr>     <chr>                 <chr>   <chr>     <chr> <chr> <chr>         <list>   
#> 1 ELEC.GEN.ALL-~ Net generation : all fuel~ thousand me~ A     "Summation of all fuels used for e~ None      EIA, U.S. Energy Inf~ USA-AK  USA-AK    2001  2019  2020-10-27T1~ <tibble ~

d$data[[1]]
#> # A tibble: 10 x 3
#>    value date        year
#>    <dbl> <date>     <int>
#>  1 6071. 2019-01-01  2019
#>  2 6247. 2018-01-01  2018
#>  3 6497. 2017-01-01  2017
#>  4 6335. 2016-01-01  2016
#>  5 6285. 2015-01-01  2015
#>  6 6043. 2014-01-01  2014
#>  7 6497. 2013-01-01  2013
#>  8 6946. 2012-01-01  2012
#>  9 6871. 2011-01-01  2011
#> 10 6760. 2010-01-01  2010

library(ggplot2)
library(tidyr)
unnest(d, cols = data) %>% ggplot(aes(factor(year), value)) + geom_col() + 
  labs(x = "Year", y = d$units, title = d$name, caption = d$description)

References

See the collection of vignette tutorials and examples as well as complete package documentation available at the eia package website.


Please note that the eia project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

ropensci_footer

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].