tidymodels / tidymodels/rsample
add dates to output of sliding_period
Open
Nobody has claimed this yet.
feature
- Dominant language
- R
- Stars
- 343
- Forks
- 67
- Avg merge
- 1h 9m
- Merged PRs (30d)
- 2
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the sliding_period() example in the issue and inspect how its splits and id columns are produced. Add start and end dates for the in-sample and assessment periods to the output, then verify that the displayed Slice1 and Slice2 values can be joined to those dates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100