From 68c920f2c28146e0f2584ffe1299d4bd7e6487b5 Mon Sep 17 00:00:00 2001 From: Chris Bailey Date: Sun, 2 Feb 2020 18:01:31 +0000 Subject: [PATCH] replaced redundant call to read_csv with httr::content --- NAMESPACE | 1 + R/nomisr-package.R | 2 +- R/utils-get-data.R | 13 ++++--------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9af9770..d187d53 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(nomis_overview) export(nomis_search) importFrom(dplyr,bind_rows) importFrom(httr,GET) +importFrom(httr,content) importFrom(httr,http_error) importFrom(httr,http_type) importFrom(httr,status_code) diff --git a/R/nomisr-package.R b/R/nomisr-package.R index 1da6650..5db781a 100644 --- a/R/nomisr-package.R +++ b/R/nomisr-package.R @@ -18,7 +18,7 @@ #' @name nomisr #' @importFrom jsonlite fromJSON #' @importFrom tibble as_tibble enframe -#' @importFrom httr http_type GET http_error status_code +#' @importFrom httr http_type GET http_error status_code content #' @importFrom readr read_csv col_double col_character #' @importFrom dplyr bind_rows #' @importFrom utils menu diff --git a/R/utils-get-data.R b/R/utils-get-data.R index 9775fdd..0cf1a6c 100644 --- a/R/utils-get-data.R +++ b/R/utils-get-data.R @@ -21,12 +21,7 @@ nomis_get_data_util <- function(query) { } df <- tryCatch({ - readr::read_csv( - api_get$url, - col_types = readr::cols( - .default = "c" - ) - ) + httr::content(api_get) }, error = function(cond) { message( @@ -48,8 +43,8 @@ nomis_get_data_util <- function(query) { if ("OBS_VALUE" %in% names(df)) { df$OBS_VALUE <- as.double(df$OBS_VALUE) } - + df - - + + }