diff --git a/DESCRIPTION b/DESCRIPTION index d6c0251..07febda 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: eia Title: API Wrapper for 'US Energy Information Administration' Open Data -Version: 0.4.1 +Version: 0.4.2 Authors@R: c(person( given = "Matthew", @@ -28,10 +28,8 @@ Imports: tibble, httr, jsonlite, - purrr, memoise, - lubridate, - readxl + lubridate Suggests: testthat (>= 3.0.0), knitr, diff --git a/NAMESPACE b/NAMESPACE index a4bc316..14316a1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,12 +11,9 @@ export(eia_dir) export(eia_facets) export(eia_get_key) export(eia_metadata) -export(eia_report) export(eia_set_key) export(eiadate_to_date) export(eiadate_to_date_seq) -export(report_drilling_productivity) importFrom(httr,GET) importFrom(httr,content) -importFrom(httr,write_disk) importFrom(tibble,tibble) diff --git a/NEWS.md b/NEWS.md index 6b09f44..30da08a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# eia 0.4.2 + +* Removed one-off, non-API, report download function that no longer works but also do not intend to support within the scope of the package. +* Removed related, no longer needed package imports. +* Updated documentation. + # eia 0.4.1 * Re-factor of `eia_data()`: diff --git a/R/reports.R b/R/reports.R index 9a50d71..b8c0438 100644 --- a/R/reports.R +++ b/R/reports.R @@ -1,61 +1,61 @@ -#' Download data for various EIA reports -#' -#' These functions download data for various EIA reports found on the EIA -#' website but not necessarily available through the EIA API. -#' -#' The wrapper function and the individual report functions do not make API -#' calls and do not require an API key. -#' -#' @param id character, the report ID. See examples for available reports. -#' @param ... arguments passed to individual report data functions. -#' -#' @return a list, typically a list of data frames -#' @export -#' -#' @examples -#' \dontrun{ -#' x <- eia_report("drilling productivity") -#' } -eia_report <- function(id, ...){ - f <- switch( - id, - "drilling productivity" = report_drilling_productivity - ) - f(...) -} +# #' Download data for various EIA reports +# #' +# #' These functions download data for various EIA reports found on the EIA +# #' website but not necessarily available through the EIA API. +# #' +# #' The wrapper function and the individual report functions do not make API +# #' calls and do not require an API key. +# #' +# #' @param id character, the report ID. See examples for available reports. +# #' @param ... arguments passed to individual report data functions. +# #' +# #' @return a list, typically a list of data frames +# #' @export +# #' +# #' @examples +# #' \dontrun{ +# #' x <- eia_report("drilling productivity") +# #' } +# eia_report <- function(id, ...){ +# f <- switch( +# id, +# "drilling productivity" = report_drilling_productivity +# ) +# f(...) +# } -#' @importFrom httr GET write_disk -#' @export -#' @rdname eia_report -report_drilling_productivity <- function(){ - url <- paste0("https://www.eia.gov/petroleum/drilling/xls/dpr-data.xlsx") - file <- file.path(tempdir(), "dpr-data.xlsx") - x <- httr::RETRY(verb = "GET", url = url, httr::write_disk(file)) - x <- tryCatch( - purrr::map(1:7, ~{ - z <- names(readxl::read_xlsx(file, .x, skip = 0, .name_repair = "minimal")) - z <- z[z != ""][-1] - x <- readxl::read_xlsx(file, .x, skip = 1, .name_repair = "minimal") - dplyr::bind_rows(x[1:5], x[c(1:2, 6:8)]) |> - dplyr::mutate(Fuel = factor(rep(z, each = nrow(x)), levels = z)) |> - dplyr::select(c(6, 1:5)) - }), - error = function(e) NULL - ) - y <- tryCatch( - readxl::read_xlsx(file, 8, .name_repair = "minimal"), - error = function(e) NULL - ) - if(is.null(x)){ - unlink(file, recursive = TRUE, force = TRUE) - message("Report not found.") - return(invisible()) - } - names(x) <- readxl::excel_sheets(file)[1:7] - unlink(file, recursive = TRUE, force = TRUE) - list( - data = dplyr::bind_rows(x, .id = "Region") |> - dplyr::mutate(Region = factor(.data[["Region"]])), - counties = y - ) -} +# #' @importFrom httr GET write_disk +# #' @export +# #' @rdname eia_report +# report_drilling_productivity <- function(){ +# url <- paste0("https://www.eia.gov/petroleum/drilling/xls/dpr-data.xlsx") +# file <- file.path(tempdir(), "dpr-data.xlsx") +# x <- httr::RETRY(verb = "GET", url = url, httr::write_disk(file)) +# x <- tryCatch( +# purrr::map(1:7, ~{ +# z <- names(readxl::read_xlsx(file, .x, skip = 0, .name_repair = "minimal")) +# z <- z[z != ""][-1] +# x <- readxl::read_xlsx(file, .x, skip = 1, .name_repair = "minimal") +# dplyr::bind_rows(x[1:5], x[c(1:2, 6:8)]) |> +# dplyr::mutate(Fuel = factor(rep(z, each = nrow(x)), levels = z)) |> +# dplyr::select(c(6, 1:5)) +# }), +# error = function(e) NULL +# ) +# y <- tryCatch( +# readxl::read_xlsx(file, 8, .name_repair = "minimal"), +# error = function(e) NULL +# ) +# if(is.null(x)){ +# unlink(file, recursive = TRUE, force = TRUE) +# message("Report not found.") +# return(invisible()) +# } +# names(x) <- readxl::excel_sheets(file)[1:7] +# unlink(file, recursive = TRUE, force = TRUE) +# list( +# data = dplyr::bind_rows(x, .id = "Region") |> +# dplyr::mutate(Region = factor(.data[["Region"]])), +# counties = y +# ) +# } diff --git a/codemeta.json b/codemeta.json index cf9b46c..cff6bbf 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,13 +8,13 @@ "codeRepository": "https://github.com/ropensci/eia", "issueTracker": "https://github.com/ropensci/eia/issues", "license": "https://spdx.org/licenses/MIT", - "version": "0.4.1", + "version": "0.4.2", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.1 (2023-06-16)", + "runtimePlatform": "R version 4.3.1 (2023-06-16 ucrt)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -180,18 +180,6 @@ "sameAs": "https://CRAN.R-project.org/package=jsonlite" }, "4": { - "@type": "SoftwareApplication", - "identifier": "purrr", - "name": "purrr", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=purrr" - }, - "5": { "@type": "SoftwareApplication", "identifier": "memoise", "name": "memoise", @@ -203,7 +191,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=memoise" }, - "6": { + "5": { "@type": "SoftwareApplication", "identifier": "lubridate", "name": "lubridate", @@ -215,19 +203,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=lubridate" }, - "7": { - "@type": "SoftwareApplication", - "identifier": "readxl", - "name": "readxl", - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, - "sameAs": "https://CRAN.R-project.org/package=readxl" - }, "SystemRequirements": null }, - "fileSize": "202.642KB" + "fileSize": "205.522KB" } diff --git a/cran-comments.md b/cran-comments.md index 0efa584..6dc4485 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,6 @@ ## Test environments -* Local Windows 10 install: R 4.3.1 +* Local Windows 10 install: R 4.3.3 * Win Builder: R-devel, R-release * Windows latest: R-release * Ubuntu latest: R-devel, R-release, R-oldrel @@ -8,7 +8,7 @@ ## Update release -* Code updates and additional unit testing. +* Fix failing functionality as requested by CRAN. ## R CMD check results diff --git a/man/eia_report.Rd b/man/eia_report.Rd deleted file mode 100644 index ae8e4c9..0000000 --- a/man/eia_report.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reports.R -\name{eia_report} -\alias{eia_report} -\alias{report_drilling_productivity} -\title{Download data for various EIA reports} -\usage{ -eia_report(id, ...) - -report_drilling_productivity() -} -\arguments{ -\item{id}{character, the report ID. See examples for available reports.} - -\item{...}{arguments passed to individual report data functions.} -} -\value{ -a list, typically a list of data frames -} -\description{ -These functions download data for various EIA reports found on the EIA -website but not necessarily available through the EIA API. -} -\details{ -The wrapper function and the individual report functions do not make API -calls and do not require an API key. -} -\examples{ -\dontrun{ -x <- eia_report("drilling productivity") -} -} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 7c3ff14..aab1862 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -20,7 +20,6 @@ reference: - title: Other functions contents: - eia_clear_cache - - eia_report - eiadate navbar: diff --git a/tests/testthat/test-reports.R b/tests/testthat/test-reports.R index e3ab01c..eaffb59 100644 --- a/tests/testthat/test-reports.R +++ b/tests/testthat/test-reports.R @@ -1,11 +1,12 @@ -test_that("eia_report returns as expected", { - x <- eia_report(id = "drilling productivity") - expect_type(x, "list") - expect_equal(length(x), 2) - expect_equal(names(x), c("data", "counties")) - v <- c("Region", "Fuel", "Month", "Rig count", "Production per rig", - "Legacy production change", "Total production") - expect_equal(names(x$data), v) - v <- c("State", "County", "StateID", "CountyID", "Region") - expect_equal(names(x$counties), v) -}) +# test_that("eia_report returns as expected", { +# skip_on_cran() +# x <- eia_report(id = "drilling productivity") +# expect_type(x, "list") +# expect_equal(length(x), 2) +# expect_equal(names(x), c("data", "counties")) +# v <- c("Region", "Fuel", "Month", "Rig count", "Production per rig", +# "Legacy production change", "Total production") +# expect_equal(names(x$data), v) +# v <- c("State", "County", "StateID", "CountyID", "Region") +# expect_equal(names(x$counties), v) +# })