-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
114 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,11 @@ Authors@R: c( | |
"Evan", "Odell", email = "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID='0000-0003-1845-808X')), | ||
person( | ||
"Paul", "Egeler", email = "[email protected]", role = c("rev", "ctb"), | ||
comment = "Reviewed package for rOpenSci: ropensci/onboarding#190")) | ||
"Paul", "Egeler", email = "[email protected]", role = c("rev", "ctb")), | ||
person( | ||
"Christophe", "Dervieux", role = c("rev"), | ||
comment = c(ORCID='0000-0003-4474-2498')) | ||
) | ||
Description: Access UK official statistics from the 'Nomis' database. | ||
'Nomis' includes data from the Census, the Labour Force Survey, DWP benefit | ||
statistics and other economic and demographic data from the Office for | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,49 @@ | ||
|
||
#' Nomis API Key | ||
#' | ||
#' | ||
#' @description Assign or reassign API key for Nomis. | ||
#' | ||
#' | ||
#' @details The Nomis API has an optional key. Using the key means that 100,000 | ||
#' rows can be returned per call, which can speed up larger data requests and | ||
#' reduce the chances of being rate limited or having requests timing out. | ||
#' | ||
#' | ||
#' @details By default, \code{nomisr} will look for the environment variable | ||
#' \code{NOMIS_API_KEY} when the package is loaded. If found, the API key will | ||
#' be stored in the session option \code{nomisr.API.key}. If you would like to | ||
#' reload the API key or would like to manually enter one in, this function | ||
#' may be used. | ||
#' | ||
#' | ||
#' @details You can sign up for an API key | ||
#' \href{https://www.nomisweb.co.uk/myaccount/userjoin.asp}{here}. | ||
#' | ||
#' | ||
#' @param check_env If TRUE, will check the environment variable | ||
#' \code{NOMIS_API_KEY} first before asking for user input. | ||
#' | ||
#' @export | ||
nomis_api_key <- function(check_env = FALSE) { | ||
|
||
if (check_env) { | ||
key <- Sys.getenv('NOMIS_API_KEY') | ||
key <- Sys.getenv("NOMIS_API_KEY") | ||
if (key != "") { | ||
message("Updating NOMIS_API_KEY environment variable...") | ||
options("nomisr.API.key" = key) | ||
return(invisible()) | ||
} else { | ||
warning("Couldn't find environment variable 'NOMIS_API_KEY'") | ||
warning("Couldn't find environment variable 'NOMIS_API_KEY'") | ||
} | ||
} | ||
|
||
if (interactive()) { | ||
key <- readline("Please enter your API key and press enter: ") | ||
} else { | ||
cat("Please enter your API key and press enter: ") | ||
key <- readLines(con = "stdin", n = 1) | ||
} | ||
|
||
if (identical(key, "")) { | ||
stop("Nomis API key entry failed", call. = FALSE) | ||
} | ||
|
||
message("Updating NOMIS_API_KEY environment variable...") | ||
options("nomisr.API.key" = key) | ||
invisible() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
context("test-load.R") | ||
|
||
test_that("package loading works", { | ||
|
||
expect_silent(library(nomisr)) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.