Skip to content

Commit

Permalink
#88 switch to alternative approach for assigning fns to list-col
Browse files Browse the repository at this point in the history
- prev approach with rlang::as_function() was taking the entire set of all previous input code including the wrapping mutate() calls
  • Loading branch information
egouldo committed Aug 14, 2024
1 parent c0a4a6b commit 7f7cc63
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions R/prepare_response_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@ prepare_response_variables <- function(ManyEcoEvo,
dat #TODO replace dummy function with actual function
}

datasets_to_standardise <- tibble(
dataset = dataset_standardise,
fns = list(standardise_response)
)

out <- out %>%
ungroup() %>%
mutate(fns = map(dataset,
~ case_match(.x,
!!{dataset_standardise} ~ "standardise_response",
.default = "process_response") %>%
rlang::as_function()))

left_join(datasets_to_standardise, by = "dataset") %>%
mutate(fns = coalesce(fns, list(process_response)),
data = map2(.x = data, .y = fns, ~ .y(.x))
)
}

return(out)

}

0 comments on commit 7f7cc63

Please sign in to comment.