Closed cgoo4 closed 2 years ago
Is it an intentional difference in behaviour that tile_tsibble retains a partial window size, but slide_tsibble does not per the example below?
tile_tsibble
slide_tsibble
Ideally I'm looking for overlapping windows that retain a partial window.
library(tidyverse) library(tsibble) #> #> Attaching package: 'tsibble' #> The following objects are masked from 'package:base': #> #> intersect, setdiff, union tribble( ~group, ~date, ~value, "A", "2020-01-01", 1, "A", "2020-01-02", 2, "A", "2020-01-03", 3, "A", "2020-01-04", 4, "A", "2020-01-05", 5, "A", "2020-01-06", 6, "B", "2020-01-02", 2, "B", "2020-01-03", 3, "B", "2020-01-04", 4, "B", "2020-01-05", 5, "B", "2020-01-06", 6 ) |> mutate(date = lubridate::ymd(date)) |> as_tsibble(index = date, key = group) |> tile_tsibble(.size = 3) #> # A tsibble: 11 x 4 [1D] #> # Key: .id, group [4] #> group date value .id #> <chr> <date> <dbl> <int> #> 1 A 2020-01-01 1 1 #> 2 A 2020-01-02 2 1 #> 3 A 2020-01-03 3 1 #> 4 B 2020-01-02 2 1 #> 5 B 2020-01-03 3 1 #> 6 B 2020-01-04 4 1 #> 7 A 2020-01-04 4 2 #> 8 A 2020-01-05 5 2 #> 9 A 2020-01-06 6 2 #> 10 B 2020-01-05 5 2 #> 11 B 2020-01-06 6 2 tribble( ~group, ~date, ~value, "A", "2020-01-01", 1, "A", "2020-01-02", 2, "A", "2020-01-03", 3, "A", "2020-01-04", 4, "A", "2020-01-05", 5, "A", "2020-01-06", 6, "B", "2020-01-02", 2, "B", "2020-01-03", 3, "B", "2020-01-04", 4, "B", "2020-01-05", 5, "B", "2020-01-06", 6 ) |> mutate(date = lubridate::ymd(date)) |> as_tsibble(index = date, key = group) |> slide_tsibble(.size = 3, .step = 3) #> # A tsibble: 9 x 4 [1D] #> # Key: .id, group [3] #> group date value .id #> <chr> <date> <dbl> <int> #> 1 A 2020-01-01 1 1 #> 2 A 2020-01-02 2 1 #> 3 A 2020-01-03 3 1 #> 4 B 2020-01-02 2 1 #> 5 B 2020-01-03 3 1 #> 6 B 2020-01-04 4 1 #> 7 A 2020-01-04 4 2 #> 8 A 2020-01-05 5 2 #> 9 A 2020-01-06 6 2
Created on 2022-05-16 by the reprex package (v2.0.1)
Will take a look at Slider
Is it an intentional difference in behaviour that
tile_tsibble
retains a partial window size, butslide_tsibble
does not per the example below?Ideally I'm looking for overlapping windows that retain a partial window.
Created on 2022-05-16 by the reprex package (v2.0.1)