Skip to contents

Alternate time points across folds so each fold spans the full series.

Usage

make_time_folds_interleave(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_interleave(df, K = 3)
#> $`0`
#> [1]  1  2  7  8 13 14 19 20
#> 
#> $`1`
#> [1]  3  4  9 10 15 16
#> 
#> $`2`
#> [1]  5  6 11 12 17 18
#>