tidyverse / dplyr

dplyr: A grammar of data manipulation
https://dplyr.tidyverse.org/
Other
4.79k stars 2.12k forks source link

c_across() docs imply a dependency on rowwise() #7015

Open charliejhadley opened 7 months ago

charliejhadley commented 7 months ago

I find the docs for c_across() imply the requirement for a rowwise() call which isn't required.

Here's a reprex using {palmerpenguins} and another using base R's mtcars

library("tidyverse")
library("palmerpenguins")

penguins %>% 
  group_by(island) %>% 
  summarise(max_dimension = max(c_across(ends_with("mm")),
                                na.rm = TRUE))
#> # A tibble: 3 × 2
#>   island    max_dimension
#>   <fct>             <dbl>
#> 1 Biscoe              231
#> 2 Dream               212
#> 3 Torgersen           210

mtcars %>% 
  select(wt, drat, carb, gear) %>% 
  group_by(gear) %>% 
  summarise(max_value = max(c_across(where(is.numeric))))
#> # A tibble: 3 × 2
#>    gear max_value
#>   <dbl>     <dbl>
#> 1     3      5.42
#> 2     4      4.93
#> 3     5      8

I haven't got a good idea of what I think could be added to the docs so I'm logging the issue now and will try to come back later