duckplyr
duckplyr copied to clipboard
mutate() now supports the argument .keep = "transmute"
Hi @krlmlr,
This merge request seeks to support the new .keep = "transmute" argument in the mutate, based on the dplyr pull request https://github.com/tidyverse/dplyr/pull/7038
Below I leave an example comparing transmute with mutate(.keep = "transmute")
example <- tibble(
group = c("a", "a", "b", "b"),
old = c(1, 2, 3, 4)
)
example <- duckplyr::as_duckplyr_df(example)
# transmute --------------------------------------------------------------------
example %>% transmute(
group,
new = old * 2,
old
)
materializing:
---------------------
--- Relation Tree ---
---------------------
Projection ["group" as group, *("old", 2.0) as new, "old" as old]
r_dataframe_scan(0x7fbd82db4148)
---------------------
-- Result Columns --
---------------------
- group (VARCHAR)
- new (DOUBLE)
- old (DOUBLE)
# A tibble: 4 × 3
group new old
<chr> <dbl> <dbl>
1 a 2 1
2 a 4 2
3 b 6 3
4 b 8 4
# mutate(.keep = "transmute") --------------------------------------------------
example %>% mutate(
.keep = "transmute",
group,
new = old * 2,
old
)
materializing:
---------------------
--- Relation Tree ---
---------------------
Projection ["group" as group, "new" as new, "old" as old]
Projection ["group" as group, "old" as old, "new" as new]
Projection ["group" as group, "old" as old, *("old", 2.0) as new]
Projection ["group" as group, "old" as old]
r_dataframe_scan(0x7fbd6485f588)
---------------------
-- Result Columns --
---------------------
- group (VARCHAR)
- new (DOUBLE)
- old (DOUBLE)
# A tibble: 4 × 3
group new old
<chr> <dbl> <dbl>
1 a 2 1
2 a 4 2
3 b 6 3
4 b 8 4
Regards,