Skip to content

Commit

Permalink
Merge pull request #184 from pharmaverse/main
Browse files Browse the repository at this point in the history
FFWD dev after hotfix
  • Loading branch information
kodesiba authored Jun 22, 2023
2 parents 6b36a10 + 678a34c commit 9ae9814
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -35,7 +35,7 @@ LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Imports:
dplyr,
dplyr (>= 1.0.0),
magrittr,
purrr,
rlang,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -57,6 +56,7 @@ 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,pivot_wider)
importFrom(utils,capture.output)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# logrx 0.2.2

- 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

- non-function objects are no longer returned as functions by `get_used_functions` (#154)
Expand Down
29 changes: 15 additions & 14 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand Down Expand Up @@ -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
#' @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
Expand Down Expand Up @@ -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)
Expand All @@ -180,23 +180,24 @@ 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()

}

Expand Down Expand Up @@ -239,7 +240,7 @@ get_library <- function(df){
mutate(library = ifelse(
!is.na(df$SYMBOL_PACKAGE),
paste0("package:", df$SYMBOL_PACKAGE),
.data$library)
.data[["library"]])
)
}

Expand Down

0 comments on commit 9ae9814

Please sign in to comment.