group order detection on mutation

This commit is contained in:
willdebras 2022-02-27 20:51:48 -06:00
Родитель 3410db5283
Коммит 0182b5b8cc
2 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -165,7 +165,18 @@ datamation_sanddance <- function(pipeline, envir = rlang::global_env(), pretty =
# Call that function with the data and mapping
if (verb != "filter") {
res[[i]] <- do.call(call_verb, list(data, mapping, toJSON = FALSE, pretty = pretty, height = height, width = width))
if(verb == "mutate") {
# Checks if the group_by occurs before this fitting
if (!length(which(stringr::str_detect(names(tidy_function_args), "group_by")))==0 &&
which(stringr::str_detect(names(tidy_function_args), "group_by")) < i) {
grouping_on_mutation <- TRUE
} else grouping_on_mutation <- FALSE
res[[i]] <- do.call(call_verb, list(data, mapping, toJSON = FALSE, pretty = pretty, height = height, width = width, grouping_on_mutation))
}
else res[[i]] <- do.call(call_verb, list(data, mapping, toJSON = FALSE, pretty = pretty, height = height, width = width))
} else if (verb == "filter") {
previous_frame <- res[[i - 1]]

Просмотреть файл

@ -5,7 +5,7 @@
#' @inheritParams datamation_sanddance
#' @inheritParams prep_specs_data
#' @noRd
prep_specs_mutate <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, height = 300, width = 300) {
prep_specs_mutate <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, height = 300, width = 300, grouping_on_mutation) {
# Get mutation function and variable
@ -41,6 +41,9 @@ prep_specs_mutate <- function(.data, mapping, toJSON = TRUE, pretty = TRUE, heig
y_type <- "null"
}
# If the grouping doesn't happen until after the mutation, set the group mapping NULL
if(!grouping_on_mutation) {mapping$groups <- NULL}
# Mapping and encoding for numeric ----
if (y_type == "numeric") {
## Extract mapping ----