tidyverts / tsibble

Tidy Temporal Data Frames and Tools
https://tsibble.tidyverts.org
GNU General Public License v3.0
528 stars 50 forks source link

summarise returns incorrect grouping for tsibble #167

Closed davidtedfordholt closed 4 years ago

davidtedfordholt commented 4 years ago

Thank you for all the work you've put into tsibble!

I'm unsure if this is something you can control or inherent to dplyr::summarise, but when I group and then summarise a tsibble object, I am left with a tsibble with proper keys but grouped by all but the last variable in the group_by statement. This does not happen when I do not call summarise. It doesn't break anything for me, as I always just ungroup afterward, but it's an odd behavior that might cause problems in more complicated workflows.

library(dplyr)
library(tsibble)

tourism %>%
    group_by(Purpose, State) %>%
    groups()

tourism %>%
    group_by(Purpose, State) %>%
    summarise(Trips = sum(Trips)) %>%
    groups()

tourism %>%
    group_by(Purpose, State, Region) %>%
    groups()

tourism %>%
    group_by(Purpose, State, Region) %>%
    summarise(Trips = sum(Trips)) %>%
    groups()