Skip to content

nest() does not respect ordering of keys #57

Closed
@mitchelloharawild

Description

@mitchelloharawild

Critical bug when nesting a tsibble, which causes misalignment of data when nesting. I suspect the issue is caused within nest.tbl_ts.


library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following object is masked from 'package:stats':
#> 
#>     filter
pedestrian_lst <- pedestrian %>%
  arrange(desc(Sensor)) %>% 
  group_by(Sensor) %>% 
  nest

pedestrian_lst %>% 
  filter(Sensor == "Birrarung Marr") %>% 
  unnest
#> # A tsibble: 17,539 x 5 [1h]
#>    Sensor         Date_Time           Date        Time Count
#>    <chr>          <dttm>              <date>     <int> <int>
#>  1 Birrarung Marr 2015-01-01 00:00:00 2015-01-01     0   746
#>  2 Birrarung Marr 2015-01-01 01:00:00 2015-01-01     1   312
#>  3 Birrarung Marr 2015-01-01 02:00:00 2015-01-01     2   180
#>  4 Birrarung Marr 2015-01-01 03:00:00 2015-01-01     3   133
#>  5 Birrarung Marr 2015-01-01 04:00:00 2015-01-01     4    44
#>  6 Birrarung Marr 2015-01-01 05:00:00 2015-01-01     5    16
#>  7 Birrarung Marr 2015-01-01 06:00:00 2015-01-01     6    13
#>  8 Birrarung Marr 2015-01-01 07:00:00 2015-01-01     7    21
#>  9 Birrarung Marr 2015-01-01 08:00:00 2015-01-01     8    39
#> 10 Birrarung Marr 2015-01-01 09:00:00 2015-01-01     9    36
#> # ... with 17,529 more rows

pedestrian %>% 
  filter(Sensor == "Birrarung Marr")
#> # A tsibble: 14,592 x 5 [1h]
#> # Key:       Sensor [1]
#>    Sensor         Date_Time           Date        Time Count
#>    <chr>          <dttm>              <date>     <int> <int>
#>  1 Birrarung Marr 2015-01-01 00:00:00 2015-01-01     0  1630
#>  2 Birrarung Marr 2015-01-01 01:00:00 2015-01-01     1   826
#>  3 Birrarung Marr 2015-01-01 02:00:00 2015-01-01     2   567
#>  4 Birrarung Marr 2015-01-01 03:00:00 2015-01-01     3   264
#>  5 Birrarung Marr 2015-01-01 04:00:00 2015-01-01     4   139
#>  6 Birrarung Marr 2015-01-01 05:00:00 2015-01-01     5    77
#>  7 Birrarung Marr 2015-01-01 06:00:00 2015-01-01     6    44
#>  8 Birrarung Marr 2015-01-01 07:00:00 2015-01-01     7    56
#>  9 Birrarung Marr 2015-01-01 08:00:00 2015-01-01     8   113
#> 10 Birrarung Marr 2015-01-01 09:00:00 2015-01-01     9   166
#> # ... with 14,582 more rows

Created on 2018-08-22 by the reprex package (v0.2.0).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions