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
Interesting interaction in summarise(across(...)) - if I try to deselect some grouping var, z, in across() and but summarise by it using .by = , it errors claiming that it doesn't exist.
Note this occurs regardless of the type of z - numeric, character, etc.
I'd expect this isn't a totally rogue thing to do - "summarise everything except this one thing, which I'd like to group by"
dat<-tibble::tibble(x=1:5,
y=1:5,
z= c(1, 1, 1, 2, 2))
dplyr::summarise(dat, across(-z, \(x) sum(x, na.rm=TRUE)))
#> # A tibble: 1 × 2#> x y#> <int> <int>#> 1 15 15dplyr::summarise(dat, across(c(x, y), \(x) sum(x, na.rm=TRUE)), .by=z)
#> # A tibble: 2 × 3#> z x y#> <dbl> <int> <int>#> 1 1 6 6#> 2 2 9 9dplyr::summarise(dat, across(!z, \(x) sum(x, na.rm=TRUE)), .by=z)
#> Error in `dplyr::summarise()`:#> ℹ In argument: `across(!z, function(x) sum(x, na.rm = TRUE))`.#> Caused by error in `across()`:#> ! Can't select columns that don't exist.#> ✖ Column `z` doesn't exist.
.cols: <tidy-select> Columns to transform. You can't select grouping columns because they are already automatically handled by the verb (i.e. summarise() or mutate()).
Interesting interaction in
summarise(across(...))
- if I try to deselect some grouping var,z
, inacross()
and but summarise by it using.by =
, it errors claiming that it doesn't exist.Note this occurs regardless of the type of
z
- numeric, character, etc.I'd expect this isn't a totally rogue thing to do - "summarise everything except this one thing, which I'd like to group by"
Created on 2024-09-18 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: