我一直在使用这个tsibble
包,但我不知道从聚合结果中删除时间分量的正确方法是什么。所以在下面的数据集中,我想要按地区和州划分平均行程。将 a转换tsibble
为 a的正确方法是tibble
(可能是,我只是不确定)还是我缺少一些选项来实现聚合?
library(tsibble)
library(dplyr)
tourism %>% group_by(Region, State) %>% summarise(Mean_trips = mean(Trips))
# A tsibble: 6,080 x 4 [1Q]
# Key: Region, State [76]
# Groups: Region [76]
Region State Quarter Mean_trips
<chr> <chr> <qtr> <dbl>
1 Adelaide South Australia 1998 Q1 165.
2 Adelaide South Australia 1998 Q2 112.
3 Adelaide South Australia 1998 Q3 148.
## This is not what I want, this is what I want:
tourism %>% as_tibble %>% group_by(Region, State) %>% summarise(Mean_trips = mean(Trips))
# A tibble: 76 x 3
# Groups: Region [76]
Region State Mean_trips
<chr> <chr> <dbl>
1 Adelaide South Australia 143.
2 Adelaide Hills South Australia 7.18