Skip to content

add dates to output of sliding_period #421

@era127

Description

@era127

It might be helpful to include the dates of the start/end of the in/out sample periods in the output of sliding_period(). This would also allow users to join the rsampling table with the Slice01, Slice02, etc labels to see a time series.

df <- data.frame(x = vctrs::new_date(c(1, 3, 4, 6, 7, 10)))
x <- sliding_period(df, x, "day", lookback = 2, assess_stop = 2, step = 2)
x$in_start_date = df$x[purrr::map_vec(x$splits, .f = function(x) min(x$in_id) )]
x$in_end_date = df$x[purrr::map_vec(x$splits, .f = function(x) max(x$in_id) )]

# Sliding period resampling 
# A tibble: 2 × 4
  splits        id     in_start_date in_end_date
  <list>        <chr>  <date>        <date>     
1 <split [2/1]> Slice1 1970-01-02    1970-01-04 
2 <split [2/1]> Slice2 1970-01-05    1970-01-07 

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions