You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dbplyr across() behavior differs from dplyr in a grouped context #1493
When using across() within a grouped context, everything() only selects all non-grouped variables. This is also documented in the code example of group_cols():
# Remove the grouping variables from mutate selections:
gdf %>% mutate_at(vars(-group_cols()), `/`, 100)
# -> No longer necessary with across()
gdf %>% mutate(across(everything(), ~ . / 100))
And not surprisingly that is also what happens:
library(dplyr)
#> #> Attache Paket: 'dplyr'#> Die folgenden Objekte sind maskiert von 'package:stats':#> #> filter, lag#> Die folgenden Objekte sind maskiert von 'package:base':#> #> intersect, setdiff, setequal, uniondf<-
tibble(
id= c(1),
y= c("a"),
z= c("a")
)
df|>
summarize(
across(everything(), \(x) "test"),
.by=id
)
#> # A tibble: 1 × 3#> id y z #> <dbl> <chr> <chr>#> 1 1 test test
When using the exact same verbs with the dbplyr backend, everthing() really seems to select every column instead:
library(dplyr)
#> #> Attache Paket: 'dplyr'#> Die folgenden Objekte sind maskiert von 'package:stats':#> #> filter, lag#> Die folgenden Objekte sind maskiert von 'package:base':#> #> intersect, setdiff, setequal, union
library(dbplyr)
#> #> Attache Paket: 'dbplyr'#> Die folgenden Objekte sind maskiert von 'package:dplyr':#> #> ident, sqldf<-
tibble(
id= c(1),
y= c("a"),
z= c("a")
)
tbl_lazy(df, dbplyr::simulate_dbi()) |>
summarize(
across(everything(), \(x) "test"),
.by=id
)
#> <SQL>#> SELECT 'test' AS `id`, 'test' AS `y`, 'test' AS `z`#> FROM `df`#> GROUP BY `id`
Activity
mgirlich commentedon May 2, 2024
Thanks for reporting. dbplyr handled groups in
across()already correctly but not forsummarise(.by).