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(<tsibble>) ignores values named as existing keys #214

Closed mitchelloharawild closed 4 years ago

mitchelloharawild commented 4 years ago
library(tsibble)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
pedestrian %>% 
  summarise(Sensor = first(Sensor))
#> # A tsibble: 17,542 x 1 [1h] <Australia/Melbourne>
#>    Date_Time          
#>    <dttm>             
#>  1 2015-01-01 00:00:00
#>  2 2015-01-01 01:00:00
#>  3 2015-01-01 02:00:00
#>  4 2015-01-01 03:00:00
#>  5 2015-01-01 04:00:00
#>  6 2015-01-01 05:00:00
#>  7 2015-01-01 06:00:00
#>  8 2015-01-01 07:00:00
#>  9 2015-01-01 08:00:00
#> 10 2015-01-01 09:00:00
#> # … with 17,532 more rows

Created on 2020-08-10 by the reprex package (v0.3.0)

earowang commented 4 years ago

Is this what's supposed to return?

library(tsibble)
library(dplyr, warn.conflicts = FALSE)
pedestrian %>%
  as_tibble() %>% 
  group_by(Date_Time) %>% 
  summarise(Sensor = first(Sensor))
#> `summarise()` ungrouping output (override with `.groups` argument)
#> # A tibble: 17,542 x 2
#>    Date_Time           Sensor        
#>    <dttm>              <chr>         
#>  1 2015-01-01 00:00:00 Birrarung Marr
#>  2 2015-01-01 01:00:00 Birrarung Marr
#>  3 2015-01-01 02:00:00 Birrarung Marr
#>  4 2015-01-01 03:00:00 Birrarung Marr
#>  5 2015-01-01 04:00:00 Birrarung Marr
#>  6 2015-01-01 05:00:00 Birrarung Marr
#>  7 2015-01-01 06:00:00 Birrarung Marr
#>  8 2015-01-01 07:00:00 Birrarung Marr
#>  9 2015-01-01 08:00:00 Birrarung Marr
#> 10 2015-01-01 09:00:00 Birrarung Marr
#> # … with 17,532 more rows

Created on 2020-08-26 by the reprex package (v0.3.0)

mitchelloharawild commented 4 years ago

Yes, this is what I had expected.