Skip to content

Commit

Permalink
submit 0.3.2 to CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlindblad committed Aug 1, 2021
1 parent 38a7043 commit 5f780f1
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 55 deletions.
4 changes: 2 additions & 2 deletions CRAN-RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This package was submitted to CRAN on 2021-03-11.
Once it is accepted, delete this file and tag the release (commit c35ef14).
This package was submitted to CRAN on 2021-07-31.
Once it is accepted, delete this file and tag the release (commit 38a7043).
28 changes: 10 additions & 18 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: tidyUSDA
Title: A Minimal Tool Set for Gathering USDA Quick Stat Data for
Analysis and Visualization
Version: 0.3.1.9000
Title: A Minimal Tool Set for Gathering USDA Quick Stat Data for Analysis
and Visualization
Version: 0.3.2
Authors@R:
c(person(given = "Brad",
family = "Lindblad",
Expand All @@ -16,37 +16,29 @@ Authors@R:
family = "Mindeman",
role = "ctb",
email = "[email protected]"))
Description: Provides a consistent API to pull United States
Department of Agriculture census and survey data from the National
Agricultural Statistics Service (NASS) QuickStats service.
Description: Provides a consistent API to pull United States Department of
Agriculture census and survey data from the National Agricultural
Statistics Service (NASS) QuickStats service.
License: MIT + file LICENSE
URL: https://bradlindblad.github.io/tidyUSDA/,
https://github.com/bradlindblad/tidyUSDA/
Depends:
R (>= 3.6)
Imports:
crayon,
curl,
dplyr,
fuzzyjoin,
ggplot2,
httr,
jsonlite,
keyring,
magrittr,
nlme,
rgdal,
purrr,
sf,
stringi,
tigris (>= 1.0),
usethis,
httr,
brio,
waldo,
diffobj,
gitcreds
tigris (>= 1.0)
Suggests:
covr,
knitr,
rgdal,
rgeos,
rmarkdown,
spelling,
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# tidyUSDA (development version)
# tidyUSDA 0.3.2

# tidyUSDA

# tidyUSDA 0.3.2
* Added error catch to https API calls

# tidyUSDA 0.3.1
* Fixed issue where input parameters with an '&' weren't encoding correctly in API call to USDA
Expand Down
115 changes: 84 additions & 31 deletions R/getQuickstat.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,27 @@ defaultCallAPI <- function(key=NULL, program=NULL, data_item=NULL, sector=NULL,
url <- gsub(" ", "%20", url)


httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")


raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
mydata <- raw
call_api <- function(url) {
httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")


raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
return(raw)
}
try_call_api <- purrr::possibly(.f = call_api, otherwise = "Error - USDA not available; try in a few mins.")
mydata <- try_call_api(url)
#
# httr::set_config(httr::config(ssl_verifypeer = 0L))
# resp <- httr::GET(url = url)
# jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")
#
#
# raw <- jsonlite::fromJSON(jsonRespText)
# raw <- raw$data
# mydata <- raw
return(mydata)

}
Expand Down Expand Up @@ -94,14 +107,27 @@ multStates <- function(key=NULL, program=NULL, data_item=NULL, sector=NULL, grou
url <- gsub("=,", "=", url)
url <- gsub(" ", "%20", url)

httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")


raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
mydata <- raw
call_api <- function(url) {
httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")


raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
return(raw)
}
try_call_api <- purrr::possibly(.f = call_api, otherwise = "Error - USDA not available; try in a few mins.")
mydata <- try_call_api(url)
#
# httr::set_config(httr::config(ssl_verifypeer = 0L))
# resp <- httr::GET(url = url)
# jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")
#
#
# raw <- jsonlite::fromJSON(jsonRespText)
# raw <- raw$data
# mydata <- raw
return(mydata)

}
Expand Down Expand Up @@ -151,13 +177,27 @@ multCounties <- function(key=NULL, program=NULL, data_item=NULL, sector=NULL, gr
url <- gsub("=,", "=", url)
url <- gsub(" ", "%20", url)

httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")

raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
mydata <- raw
call_api <- function(url) {
httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")


raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
return(raw)
}
try_call_api <- purrr::possibly(.f = call_api, otherwise = "Error - USDA not available; try in a few mins.")
mydata <- try_call_api(url)
#
# httr::set_config(httr::config(ssl_verifypeer = 0L))
# resp <- httr::GET(url = url)
# jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")
#
#
# raw <- jsonlite::fromJSON(jsonRespText)
# raw <- raw$data
# mydata <- raw
return(mydata)

}
Expand Down Expand Up @@ -218,14 +258,27 @@ multStatesandCounties <- function(key=NULL, program=NULL, data_item=NULL, sector
url <- gsub("=,", "=", url)
url <- gsub(" ", "%20", url)

httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")


raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
mydata <- raw
call_api <- function(url) {
httr::set_config(httr::config(ssl_verifypeer = 0L))
resp <- httr::GET(url = url)
jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")


raw <- jsonlite::fromJSON(jsonRespText)
raw <- raw$data
return(raw)
}
try_call_api <- purrr::possibly(.f = call_api, otherwise = "Error - USDA not available; try in a few mins.")
mydata <- try_call_api(url)
#
# httr::set_config(httr::config(ssl_verifypeer = 0L))
# resp <- httr::GET(url = url)
# jsonRespText <- httr::content(resp,as="text", encoding = "UTF-8")
#
#
# raw <- jsonlite::fromJSON(jsonRespText)
# raw <- raw$data
# mydata <- raw
return(mydata)

}
Expand Down
6 changes: 3 additions & 3 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Hotfix issue with & encoding in API call
Fix issue where API call did not fail gracefully, per Brian Ripley request.

## Test environments
* local Linux Mint 20.1, R 4.0.3
* ubuntu 16.04 (on travis-ci), R 3.6.1
* local Linux Mint 20.2, R 4.1.0
* ubuntu 20.04 (on github-ci), R 4.0.3


## R CMD check results
Expand Down

0 comments on commit 5f780f1

Please sign in to comment.