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

Closes #218 modified row merge #219

Merged
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
2 changes: 1 addition & 1 deletion 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.3.0
Version: 0.3.1
Authors@R:
c(
person(given = "Nathan",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ importFrom(dplyr,group_by)
importFrom(dplyr,mutate)
importFrom(dplyr,rename_with)
importFrom(dplyr,select)
importFrom(dplyr,summarize)
importFrom(dplyr,ungroup)
importFrom(magrittr,"%>%")
importFrom(miniUI,gadgetTitleBar)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# logrx 0.3.1

- Hotfix to update used and unapproved packages and functions writing (#218)

# logrx 0.3.0

- Moved website theme to bootstrap 5, enabled search (#179)
Expand Down
9 changes: 7 additions & 2 deletions R/writer.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ write_masked_functions <- function(){
#' @return Formatted vector of used package functions
#' @export
#'
#' @importFrom dplyr summarize
#' @importFrom purrr map2
#' @importFrom stats aggregate
#'
Expand All @@ -153,7 +154,9 @@ write_masked_functions <- function(){
write_used_functions <- function(){
used_functions_list <- get_log_element("used_packages_functions")

combined <- aggregate(function_name~library, used_functions_list, paste)
combined <- used_functions_list %>%
group_by(library) %>%
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicholas-masel I'm not sure what's downstream but does this dataframe need to be ungrouped for any reason down the line? Not sure if an ungroup() is needed after the summarize() or not

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kodesiba Good comment and I checked into the documentation to be sure. Since I am using summarize() after group() and I only have one group, the resulting df is ungrouped as the last grouping is dropped by default.

From summarize():

When .groups is not specified, it is chosen based on the number of rows of the results:
If all the results have 1 row, you get "drop_last".

.groups - Grouping structure of the result.
"drop_last": dropping the last level of grouping. This was the only supported option before version 1.0.0.

summarize(function_name = paste0(.data[["function_name"]], collapse = ", "))

map2(combined$library, combined$function_name, ~paste(paste0("{", .x, "}"), paste0(.y, collapse = ", "))) %>%
unname() %>%
Expand Down Expand Up @@ -183,7 +186,9 @@ write_unapproved_functions <- function(){
return("No unapproved packages or functions used")
}

combined <- aggregate(function_name~library, unapproved_functions_list, paste)
combined <- unapproved_functions_list %>%
group_by(library) %>%
summarize(function_name = paste0(.data[["function_name"]], collapse = ", "))

map2(combined$library, combined$function_name, ~paste(paste0("{", .x, "}"), paste0(.y, collapse = ", "))) %>%
unname() %>%
Expand Down
Loading