Skip to content

Commit

Permalink
Get correct column order
Browse files Browse the repository at this point in the history
  • Loading branch information
markfairbanks committed Dec 26, 2024
1 parent ec1dd71 commit bb9a46b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/step-subset-transmute.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit bb9a46b

Please sign in to comment.