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
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`
When using
across()
within a grouped context,everything()
only selects all non-grouped variables. This is also documented in the code example ofgroup_cols()
:And not surprisingly that is also what happens:
Created on 2024-04-30 with reprex v2.1.0
When using the exact same verbs with the dbplyr backend,
everthing()
really seems to select every column instead:Created on 2024-04-30 with reprex v2.1.0
I expect this to result in
The text was updated successfully, but these errors were encountered: