Skip to content

Commit

Permalink
style!: explicitly call by = arg on joins
Browse files Browse the repository at this point in the history
docs: Add `@details` and @import*` tags

refs: #97
  • Loading branch information
egouldo committed Aug 27, 2024
1 parent d47c02b commit 7a9e9ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
13 changes: 9 additions & 4 deletions R/generate_expertise_subsets.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,28 @@ generate_expertise_subsets <- function(ManyEcoEvo, expert_subset) {
# NOTE: should be run *after* computing Zr with compute_MA_inputs()
out <- ManyEcoEvo %>%
filter(publishable_subset == "All" & exclusion_set == "complete") %>%
mutate(data = map(.x = data, .f = dplyr::semi_join, expert_subset)) %>%
mutate(data =
map(.x = data,
.f = dplyr::semi_join,
expert_subset,
by = join_by(response_id, TeamIdentifier))) %>%
mutate(
diversity_data =
map2(
.x = diversity_data,
.y = data,
.f = ~ semi_join(.x, .y) %>% distinct()
.f = ~ semi_join(.x, .y, join_by(id_col)) %>%
distinct()
)
) %>%
mutate(expertise_subset = "expert")

# THEN BIND ROWS WITH PREVIOUS DATASETS
out <- bind_rows(
ManyEcoEvo %>%
mutate(expertise_subset = "All"),
out
)

return(out)
}
10 changes: 8 additions & 2 deletions R/generate_rating_subsets.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
#' @export
#' @family Multi-dataset Wrapper Functions
#' @family targets-pipeline functions
#' @details
#' To be executed on a ManyEcoEvo dataframe after the `compute_MA_inputs()` function. This function generates two subsets of data based on the peer review ratings for both complete and partial exclusion datasets for both `yi` and `Zr` estimates. The subsets are generated based on the `PublishableAsIs` column in the `data` list-column. The subsets are named `data_flawed` and `data_flawed_major` and are created by filtering out the data points with the `PublishableAsIs` values of `"deeply flawed and unpublishable"` and `"publishable with major revision"` respectively. The `diversity_data` list-column is also updated to reflect the new subsets of data.
#' @import dplyr
#' @importFrom purrr map2 map
#' @importFrom forcats fct_relevel as_factor
#' @importFrom tidyr unnest pivot_longer nest
#' @importFrom stringr str_detect
generate_rating_subsets <- function(ManyEcoEvo) {
# NOTE: should be run *after* computing Zr with compute_MA_inputs()

out <- ManyEcoEvo %>%
filter(exclusion_set == "complete" | exclusion_set == "partial") %>%
Expand Down Expand Up @@ -87,7 +93,7 @@ generate_rating_subsets <- function(ManyEcoEvo) {
map2(
.x = diversity_data,
.y = data,
.f = ~ semi_join(.x, .y) %>% distinct()
.f = ~ semi_join(.x, .y, by = join_by(id_col)) %>% distinct()
)
)

Expand Down
3 changes: 2 additions & 1 deletion R/generate_yi_subsets.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ generate_yi_subsets <- function(yi_analysis) {
map2(
.x = diversity_data,
.y = data,
.f = ~ semi_join(.x, .y) %>% distinct()
.f = ~ semi_join(.x, .y,
by = join_by(id_col)) %>% distinct()
)
)

Expand Down

0 comments on commit 7a9e9ba

Please sign in to comment.