From 88d0240255e7205cb403604d98b512c065752c0d Mon Sep 17 00:00:00 2001 From: Nathan Kosiba Date: Tue, 9 May 2023 10:37:15 -0400 Subject: [PATCH 1/2] updates to align with updates to tidyselect and dplyr functionality --- DESCRIPTION | 4 ++-- NAMESPACE | 2 ++ NEWS.md | 4 ++++ R/get.R | 26 ++++++++++++++------------ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9eed103..4a5b802 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: logrx Title: A Logging Utility Focus on Clinical Trial Programming Workflows -Version: 0.2.1 +Version: 0.2.2 Authors@R: c( person(given = "Nathan", @@ -35,7 +35,7 @@ LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 Imports: - dplyr, + dplyr (>= 1.0.0), magrittr, purrr, rlang, diff --git a/NAMESPACE b/NAMESPACE index bc32ecc..4a6b5e4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -57,7 +57,9 @@ importFrom(stringr,str_replace) importFrom(stringr,str_replace_all) importFrom(stringr,str_starts) importFrom(tibble,tibble) +importFrom(tidyr,all_of) importFrom(tidyr,complete) +importFrom(tidyr,everything) importFrom(tidyr,pivot_wider) importFrom(utils,capture.output) importFrom(utils,getParseData) diff --git a/NEWS.md b/NEWS.md index 46a8d26..cbd8a56 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# logrx 0.2.2 + + - hotfix for update to `across()` and `.data$var` updates in source packages (#172) + # logrx 0.2.1 - non-function objects are no longer returned as functions by `get_used_functions` (#154) diff --git a/R/get.R b/R/get.R index 9870557..c0740b2 100644 --- a/R/get.R +++ b/R/get.R @@ -18,7 +18,7 @@ get_logrx_metadata <- function(){ logrx_session_info <- session_info()$packages %>% - filter(.data$package == "logrx") + filter(.data[["package"]] == "logrx") logrx_metadata <- list( info = paste0("This log was generated using logrx ", @@ -140,7 +140,7 @@ get_masked_functions <- function(){ #' #' @return tibble with `library` and `function_name` #' @importFrom dplyr select distinct across mutate coalesce group_by ungroup -#' @importFrom tidyr pivot_wider complete +#' @importFrom tidyr pivot_wider complete all_of everything #' @importFrom purrr safely #' @importFrom tibble tibble #' @importFrom utils getParseData @@ -171,7 +171,7 @@ get_used_functions <- function(file){ } tokens <- getParseData(ret$result) %>% - filter(.data$token %in% c("SYMBOL_FUNCTION_CALL", "SPECIAL", "SYMBOL_PACKAGE")) + filter(.data[["token"]] %in% c("SYMBOL_FUNCTION_CALL", "SPECIAL", "SYMBOL_PACKAGE")) if(nrow(tokens) == 0) { return (NULL) @@ -180,23 +180,25 @@ get_used_functions <- function(file){ # grouping and complete to ensure all three columns carry through after pivot # regardless if seen in the parsed data filtered_tokens <- tokens %>% - mutate(token = factor(.data$token, + mutate(token = factor(.data[["token"]], c("SYMBOL_FUNCTION_CALL", "SPECIAL", "SYMBOL_PACKAGE"))) %>% - group_by(.data$line1, .data$parent) %>% - complete(token = .data$token) + group_by(.data[["line1"]], .data[["parent"]]) %>% + complete(token = .data[["token"]]) wide_tokens <- pivot_wider(filtered_tokens, - id_cols = c(.data$line1, .data$parent), - values_from = .data$text, - names_from = .data$token) %>% + id_cols = all_of(c("line1", "parent")), + values_from = "text", + names_from = "token") %>% ungroup() combine_tokens <- wide_tokens %>% - mutate(function_name = coalesce(.data$SYMBOL_FUNCTION_CALL, .data$SPECIAL)) + mutate(function_name = coalesce(.data[["SYMBOL_FUNCTION_CALL"]], + .data[["SPECIAL"]])) get_library(combine_tokens) %>% - select(.data$function_name, .data$library) %>% - distinct(across()) + select(all_of(c("function_name", "library"))) %>% + distinct(across(.cols = everything(), + .fns = NULL)) } From 5eaf22c65999f561d03e60e41819fefe8d0928bd Mon Sep 17 00:00:00 2001 From: Nathan Kosiba Date: Thu, 15 Jun 2023 09:08:41 -0400 Subject: [PATCH 2/2] more hotfix updates after team discussion --- NAMESPACE | 2 -- NEWS.md | 3 ++- R/get.R | 9 ++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 4a6b5e4..459e1d7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,7 +9,6 @@ export(log_write) export(write_log_header) export(write_unapproved_functions) export(write_used_functions) -importFrom(dplyr,across) importFrom(dplyr,anti_join) importFrom(dplyr,coalesce) importFrom(dplyr,distinct) @@ -59,7 +58,6 @@ importFrom(stringr,str_starts) importFrom(tibble,tibble) importFrom(tidyr,all_of) importFrom(tidyr,complete) -importFrom(tidyr,everything) importFrom(tidyr,pivot_wider) importFrom(utils,capture.output) importFrom(utils,getParseData) diff --git a/NEWS.md b/NEWS.md index cbd8a56..c8d7428 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # logrx 0.2.2 - - hotfix for update to `across()` and `.data$var` updates in source packages (#172) + - Hotfix to remove unnecessary `across()` and update `.data$var` top new syntax to match updates in source packages (#172) + - Add `{dplyr}` version requirement # logrx 0.2.1 diff --git a/R/get.R b/R/get.R index c0740b2..92f4ec7 100644 --- a/R/get.R +++ b/R/get.R @@ -139,8 +139,8 @@ get_masked_functions <- function(){ #' @param file File path of file to run #' #' @return tibble with `library` and `function_name` -#' @importFrom dplyr select distinct across mutate coalesce group_by ungroup -#' @importFrom tidyr pivot_wider complete all_of everything +#' @importFrom dplyr select distinct mutate coalesce group_by ungroup +#' @importFrom tidyr pivot_wider complete all_of #' @importFrom purrr safely #' @importFrom tibble tibble #' @importFrom utils getParseData @@ -197,8 +197,7 @@ get_used_functions <- function(file){ get_library(combine_tokens) %>% select(all_of(c("function_name", "library"))) %>% - distinct(across(.cols = everything(), - .fns = NULL)) + distinct() } @@ -241,7 +240,7 @@ get_library <- function(df){ mutate(library = ifelse( !is.na(df$SYMBOL_PACKAGE), paste0("package:", df$SYMBOL_PACKAGE), - .data$library) + .data[["library"]]) ) }