Skip to contents

Split unique time points into contiguous blocks, returning row indices for each fold.

Usage

make_time_folds(df, time_col = "t", K = 5)

Arguments

df

Data frame containing a time column.

time_col

Name of the time column. Defaults to `"t"`.

K

Number of folds.

Value

A list of integer vectors with row indices for each fold.

Examples

df <- data.frame(t = rep(1:10, each = 2))
make_time_folds(df, K = 2)
#> $`1`
#>  [1]  1  2  3  4  5  6  7  8  9 10
#> 
#> $`2`
#>  [1] 11 12 13 14 15 16 17 18 19 20
#>