From bb9a46bea25e46f3616ad2b620b499560ae4dc46 Mon Sep 17 00:00:00 2001 From: markfairbanks Date: Thu, 26 Dec 2024 12:04:18 -0700 Subject: [PATCH] Get correct column order --- R/step-subset-transmute.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/R/step-subset-transmute.R b/R/step-subset-transmute.R index 0faaeafa..0e5f6754 100644 --- a/R/step-subset-transmute.R +++ b/R/step-subset-transmute.R @@ -14,8 +14,9 @@ #' dt %>% transmute(name, sh = paste0(species, "/", homeworld)) transmute.dtplyr_step <- function(.data, ...) { out <- mutate(.data, ..., .keep = "none") - old_vars <- intersect(.data$vars, out$vars) - new_vars <- setdiff(out$vars, .data$vars) - vars <- c(old_vars, new_vars) - select(out, all_of(vars)) + cols_expr <- names(capture_new_vars(.data, ...)) + cols_group <- group_vars(.data) + cols_group <- setdiff(cols_group, cols_expr) + cols_retain <- c(cols_group, cols_expr) + select(out, all_of(cols_retain)) }