Utility function to create folds of data, used in cross-validation proceidures.
The implementation is from the gbex
R
package
Arguments
- y
Numerical vector of observations
- num_folds
Number of folds to create.
- stratified
Logical value. If
TRUE
, the folds are stratified alongrank(y)
.
Examples
make_folds(rnorm(30), 5)
#> [1] 3 5 4 5 5 4 3 3 1 2 3 2 5 1 5 3 1 1 1 5 2 2 4 1 4 3 4 2 2 4