Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should summarise.data.frame respect .groups="rowwise"? #5422

Closed
gergness opened this issue Jul 18, 2020 · 0 comments · Fixed by #5470
Closed

Should summarise.data.frame respect .groups="rowwise"? #5422

gergness opened this issue Jul 18, 2020 · 0 comments · Fixed by #5470

Comments

@gergness
Copy link
Contributor

This is admittedly a small niche, but noticed the inconsistency when checking that my method matched for summarise matched dplyr's behavior.

In most situations this summarise would return a single row data.frame and so the groups wouldn't matter, but because we can now return multiple rows, it seems inconsistent to me.

library(dplyr)

df <- mtcars %>% 
  summarize(x = range(mpg), .groups = "rowwise")

df
#>      x
#> 1 10.4
#> 2 33.9

inherits(df, "rowwise_df") # expected TRUE
#> [1] FALSE
class(df)
#> [1] "data.frame"

df_grp <- mtcars %>% 
  group_by(cyl) %>% 
  summarize(x = range(mpg), .groups = "rowwise")

df_grp
#> # A tibble: 6 x 2
#> # Rowwise:  cyl
#>     cyl     x
#>   <dbl> <dbl>
#> 1     4  21.4
#> 2     4  33.9
#> 3     6  17.8
#> 4     6  21.4
#> 5     8  10.4
#> 6     8  19.2

inherits(df_grp, "rowwise_df")
#> [1] TRUE
class(df_grp)
#> [1] "rowwise_df" "tbl_df"     "tbl"        "data.frame"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant