From acf6b4931369e874013a16cca3fca4d0c4586d02 Mon Sep 17 00:00:00 2001 From: Sebastian Kopf Date: Mon, 19 Oct 2020 13:10:36 -0600 Subject: [PATCH] cleanup local scope evaluation helpers these caused the package load errors --- DESCRIPTION | 2 +- R/nse.R | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8e3da2a9..5c12dc00 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/R/nse.R b/R/nse.R index 2db07874..eac0ab54 100644 --- a/R/nse.R +++ b/R/nse.R @@ -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