Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with global environment CU-8677zdvv4 #63

Open
wants to merge 15 commits into
base: DEV
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: pipr
Title: Client for the PIP API
Title: Client for the Poverty and Inequality Platform ('PIP') API
Version: 1.0.0
Authors@R:
c(person(given = "Tony",
Expand All @@ -14,23 +14,24 @@ Authors@R:
family = "Shah",
role = "aut",
email = "[email protected]"),
person(given = "R. Andrés",
person(given = "R.Andrés",
family = "Castañeda",
role = "aut",
email = "[email protected]"),
person(given = "World Bank",
role = "cph")
)
Description: Provides an interface to compute poverty and inequality
Description: An interface to compute poverty and inequality
indicators for more than 160 countries and regions from the World
Bank's database of household surveys.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
URL: https://github.com/worldbank/pipr,
https://worldbank.github.io/pipr/
URL: https://worldbank.github.io/pipr/,
https://github.com/worldbank/pipr,
<https://pip.worldbank.org/api>
BugReports: https://github.com/worldbank/pipr/issues
Suggests:
covr,
Expand All @@ -56,9 +57,6 @@ Imports:
jsonlite,
tibble,
purrr,
memoise,
cachem,
data.table,
cli,
rlang,
utils
Expand Down
13 changes: 0 additions & 13 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,7 @@ export(call_aux)
export(check_api)
export(display_aux)
export(get_aux)
export(get_countries)
export(get_cpi)
export(get_dictionary)
export(get_gdp)
export(get_hfce)
export(get_incgrp_coverage)
export(get_interpolated_means)
export(get_pip_info)
export(get_pop)
export(get_pop_region)
export(get_ppp)
export(get_region_coverage)
export(get_regions)
export(get_stats)
export(get_survey_means)
export(get_versions)
export(get_wb)
16 changes: 7 additions & 9 deletions R/aaa.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.pip <- new.env(parent = emptyenv())
.pip <- new.env(parent = emptyenv())
.pipcache <- new.env(parent = emptyenv())


#' Set auxiliary table in .pip environment for later call
Expand All @@ -11,13 +12,13 @@
#' @keywords internal
set_aux <- function(table,
value,
force = FALSE) {
replace = FALSE) {
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Evaluate if exists --------

to_set <- 1
if (rlang::env_has(.pip, table)) {
if (force == FALSE) {
if (isFALSE(replace)) {
cli::cli_alert("Table {.field {table}} already exists.")
to_set <- utils::menu(c("Replace with new table", "Abort"))
}
Expand All @@ -28,10 +29,7 @@ set_aux <- function(table,

if (to_set == 2) {
msg <- c("Setting {.field {table}} into {.code .pip} aborted")
cli::cli_abort(msg,
class = "stamp_error",
wrap = TRUE
)
cli::cli_abort(msg, wrap = TRUE)
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -68,12 +66,12 @@ set_aux <- function(table,
#' @examples
#' # call one table
#'
#' get_aux("gdp", assign_tb = TRUE, force = TRUE)
#' get_aux("gdp", assign_tb = TRUE, replace = TRUE)
#' call_aux("gdp")
#'
#' # see the name of several tables in memory
#' tb <- c("cpi", "ppp", "pop")
#' lapply(tb, get_aux, assign_tb = TRUE, force = TRUE)
#' lr <- lapply(tb, get_aux, assign_tb = TRUE, replace = TRUE)
#' call_aux()
call_aux <- function(table = NULL) {

Expand Down
Loading