Skip to content

Commit

Permalink
cleanup local scope evaluation helpers
Browse files Browse the repository at this point in the history
these caused the package load errors
  • Loading branch information
Sebastian Kopf committed Oct 19, 2020
1 parent cb99154 commit acf6b49
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: isoreader
Title: Read Stable Isotope Data Files
Description: Interface to the raw data file formats commonly encountered in scientific disciplines that make use of stable isotopes.
Version: 1.2.5
Version: 1.2.6
Authors@R: person("Sebastian", "Kopf", email = "sebastian.kopf@colorado.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-2044-0201"))
URL: https://github.com/isoverse/isoreader
BugReports: https://github.com/isoverse/isoreader/issues
Expand Down
14 changes: 1 addition & 13 deletions R/nse.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,12 @@ eval_select_pos_to_cols <- function(pos, data) {
return(cols)
}

# note: uses tidyselect:eval_select because vars_select is in questioning stage
# note: force local scope to avoid conflicts with variables in the global environment
# force local evaluation of tidyselect::eval_select
local_eval_select <- local(function(expr, data, ...) {
tidyselect::eval_select(expr, data = data, ...)
}, as.environment(2))

# force local evaluation of tidyselect::eval_rename
local_eval_rename <- local(function(expr, data, ...) {
tidyselect::eval_rename(expr, data = data, ...)
}, as.environment(2))

# safe local evaluation of tidyselect::eval_select
# note: don't use purrr::safely as it invalidates the local scope!
# @return list(return = value, error = NULL) if successful or list(return = NULL, error = character) if failed
safe_local_eval_select <- function(expr, data, ...) {
# try catch find positions
pos <- tryCatch(local_eval_select(expr, data, ...), error = conditionMessage)
pos <- tryCatch(tidyselect::eval_select(expr, data, env = as.environment(2), ...), error = conditionMessage)
if (is.integer(pos))
return(list(result = pos, error = NULL))
else
Expand Down

0 comments on commit acf6b49

Please sign in to comment.